How to upload large size video

I am uploading the video using Syncfusion FILE uploader. While uploading the video size 200MB it shows me an error. My controller type is  directoryUpload="true".


The file size is too large. 


I am uploading videos in which some of them are large size let's say 200MB and some of them are small size 50MB. 


Can you please tell me how to increase file uploading size? 


<ejs-uploader id="upVideos" selected="onSelect"

allowedExtensions=".mp4" asyncSettings="@asyncSettingsVideo" directoryUpload="true" success="onSuccess"></ejs-uploader>




8 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team March 18, 2022 07:58 AM UTC

Hi Harshida, 

We suggest you to increase the maxFileSize property to specify the maximum allowed file size to be uploaded in bytes. 


Also, You can resolve this issue using maxAllowedContentLength attribute in your webconfig file. This is optional uint attribute. Specifies the maximum length of content in a request, in bytes. The default value is 30000000, which is approximately 28.6MB.    

[web.config]    

<security>    
      <requestFiltering>    
        <!-- This will handle requests up to 50MB -->    
        <requestLimitsmaxAllowedContentLength="52428800" />     
      </requestFiltering>    
</security>    


Regards, 
Ponmani M 




HP Harshida Parmar March 18, 2022 12:13 PM UTC

Thank you for your reply... As I said in the beginning I am uploading the folder in which I have to upload several videos some of them have a size 200MB, 1Gb, 500MB, or anything so your above code will work in that?


The number of videos in the folder is not fixed.


And I am developing my website using DOT NET CORE MVC C#.




HP Harshida Parmar March 18, 2022 12:54 PM UTC

I have tried your code and it is not working. Please provide me with the proper solution.

Here is my code. 


public void SaveVideo(IList<IFormFile> chunkFile, IList<IFormFile> formFileVideo)
{
long size = 0;

try
{
foreach (var file in formFileVideo)
{
var filename = ContentDispositionHeaderValue
.Parse(file.ContentDisposition)
.FileName
.Trim('"');
var folders = filename.Split('/');
var uploaderFilePath = hostingEnv.WebRootPath;
// for Directory upload
if (folders.Length > 1)
{
for (var i = 0; i < folders.Length - 1; i++)
{
var newFolder = uploaderFilePath + $@"\{folders[i]}";
Directory.CreateDirectory(newFolder);
uploaderFilePath = newFolder;
filename = folders[i + 1];
}
}
filename = uploaderFilePath + $@"\{filename}";

size += file.Length;
if (!System.IO.File.Exists(filename))
{
using (FileStream fs = System.IO.File.Create(filename))
{
file.CopyTo(fs);
fs.Flush();
}


}
}
}
catch (Exception e)
{
Response.Clear();
Response.StatusCode = 204;
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File failed to upload";
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message;
}
}




 <ejs-uploader id="formFileVideo" selected="onSelect"
                              allowedExtensions=".mp4"
                              asyncSettings="@asyncSettingsVideo" directoryUpload="true" success="onSuccess">
</ejs-uploader>


@{
    var asyncSettingsVideo = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = @Url.Content("~/ProgressbarUploadFiles/SaveVideo/"), RemoveUrl = @Url.Content("~/UploadFiles/RemoveVideo") };
}


PM Ponmani Murugaiyan Syncfusion Team March 22, 2022 02:44 AM UTC

Hi Harshida, 

You can increase the uploading file size using the maxFileSize property also, you can set the chunksize for chunk uploader. Along with previously suggested solution to enable in the maxAllowedContentLength in web config file. 

@{ 
    var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = https://localhost:44358/Home/Save, RemoveUrl = https://localhost:44358/Home/Remove, ChunkSize = 102400 }; 
} 
<ejs-uploader id="UploadFiles" asyncSettings="@asyncSettings" directoryUpload="true" maxFileSize="100000000" ></ejs-uploader> 

// Upload method for chunk-upload and normal upload 
        public void Save(IList<IFormFile> chunkFile, IList<IFormFile> UploadFiles) 
        { 
            var customFormData = Request.Form["name"]; 
            long size = 0; 
            try 
            { 
                // for chunk-upload 
                foreach (var file in chunkFile) 
                { 
                    var filename = ContentDispositionHeaderValue 
                                        .Parse(file.ContentDisposition) 
                                        .FileName 
                                        .Trim('"'); 
                    filename = hostingEnv.WebRootPath + $@"\{filename}"; 
                    size += file.Length; 
 
                    if (!System.IO.File.Exists(filename)) 
                    { 
                        using (FileStream fs = System.IO.File.Create(filename)) 
                        { 
                            file.CopyTo(fs); 
                            fs.Flush(); 
                        } 
                    } 
                    else 
                    { 
                        using (FileStream fs = System.IO.File.Open(filename, FileMode.Append)) 
                        { 
                            file.CopyTo(fs); 
                            fs.Flush(); 
                        } 
                    } 
                } 
            } 
            catch (Exception e) 
            { 
                Response.Clear(); 
                Response.StatusCode = 204; 
                Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File failed to upload"; 
                Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message; 
            } 
 
            // for normal upload 
            try 
            { 
                foreach (var file in UploadFiles) 
                { 
                    var filename = ContentDispositionHeaderValue 
                                    .Parse(file.ContentDisposition) 
                                    .FileName 
                                    .Trim('"'); 
                    filename = hostingEnv.WebRootPath + $@"\{filename}"; 
                    size += file.Length; 
                    if (!System.IO.File.Exists(filename)) 
                    { 
                        using (FileStream fs = System.IO.File.Create(filename)) 
                        { 
                            file.CopyTo(fs); 
                            fs.Flush(); 
                        } 
                    } 
                } 
            } 
            catch (Exception e) 
            { 
                Response.Clear(); 
                Response.StatusCode = 204; 
                Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File failed to upload"; 
                Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message; 
            } 
        } 


Kindly check with the attached sample for reference. 

Regards, 
Ponmani M 



Marked as answer

HP Harshida Parmar replied to Ponmani Murugaiyan March 29, 2022 08:22 AM UTC

OK, But CHUNK SIZE SHOWS ME ERROR.



PM Ponmani Murugaiyan Syncfusion Team March 30, 2022 03:16 PM UTC

Hi Harshida,


We request you to share the additional details about your reported error like error screenshot and in which scenario the error occurs to investigate further in our end.


Regards,

Ponmani M



HP Harshida Parmar March 31, 2022 10:44 AM UTC

Well, the issue is solved by my team head. 

Thank you for your time.



PM Ponmani Murugaiyan Syncfusion Team April 1, 2022 04:06 AM UTC

Hi Harshida,


We are glad to hear that the issue has been resolved.


Regards,

Ponmani M


Loader.
Up arrow icon