This is a migrated thread and some comments may be shown as answers.

MaxFileSize Limitation

2 Answers 578 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Jamie
Top achievements
Rank 1
Jamie asked on 22 Sep 2015, 09:10 PM

I am currently developing a web application using the RadAsynUpload control with a "ChunkSize" set to 4MB. I am now looking to ​prevent my users ​from uploading files larger than 6GB. The RadAsyncUpload control has a "MaxFileSize" property, but unfortunately the value is factored in bytes and the data type is only defined as an integer. With this limitation, the "MaxFileSize" cannot be set above 2GB (2,147,483,647 bytes). If I do not set the "MaxFileSize" property on the RadAsyncUpload control, I can successfully upload 6GB and larger files. Because I am using the chuck upload feature, I've configured my web.config file to handle uploads slightly larger than 4MB (the chunk size). 

 

Does anyone have a workaround for this? Thanks!

2 Answers, 1 is accepted

Sort by
0
Jamie
Top achievements
Rank 1
answered on 23 Sep 2015, 12:43 PM

As a possible workaround, I've implemented the client-side JavaScript event "OnClientProgressUpdating" to retrieve the selected file size. If the size is greater than 6GB, I cancel the upload, remove the file from the upload control, and finally alert the end-user.

If a better solution exists, or the Telerik control can be updated (or overridden) to use another data type (long?) for the "MaxFileSize" property, I'd be glad to hear about it. Thanks!

0
Hristo Valyavicharski
Telerik team
answered on 25 Sep 2015, 04:53 PM
Hi Jamie,

You are right. MaxFileSize is interger. That's why you can try to read file's size with File Api and cancel uploading:

      <script type="text/javascript">
            var size = 0;

            function fileSelected(sender, args) {
                // Read file size with File API
                size = args.get_fileInputField().files[0].size;
                
            }

            function fileUploading(sender, args) {
                // Cancel uploading
                if (size > 6442450944) {
                    args.get_cancel(true);
                }
                size = 0;
            }
        </script>


     <telerik:RadAsyncUpload runat="server" ID="asyncUpload" OnClientFileUploading="fileUploading" 
            OnClientFileSelected="fileSelected" TargetFolder="~/Uploads"></telerik:RadAsyncUpload>



I hope this helps.

Regards,
Hristo Valyavicharski
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
AsyncUpload
Asked by
Jamie
Top achievements
Rank 1
Answers by
Jamie
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or