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>
|
<security>
<requestFiltering>
<!-- This will handle requests up to 50MB -->
<requestLimitsmaxAllowedContentLength="52428800" />
</requestFiltering>
</security> |
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#.
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") };
}
|
@{
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;
}
} |
OK, But CHUNK SIZE SHOWS ME ERROR.
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
Well, the issue is solved by my team head.
Thank you for your time.
Hi Harshida,
We are glad to hear that the issue has been resolved.
Regards,
Ponmani M