Hi,
I am using http://demos.telerik.com/aspnet-mvc/upload/chunkupload to upload video file around 2 GB using chunk of 10 MB, all setting in config has been done.
It worked on Firefox, Chrome and IE with no issue, great tool.
But when I tried to upload using safari on windows 10 OS, the same code do not worked and it seems it is in infinite loop and file size keeps increasing...
Config setting is as below:
<httpRuntime targetFramework="4.5" maxRequestLength="2147483647"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647"/>
</requestFiltering>
</security>
.cshtml:
@(Html.Kendo().Upload()
.Name("files")
.Async(a => a
.Save("ChunkSave", "Upload")
.Remove("Remove", "Upload")
.AutoUpload(true)
.ChunkSize(20000000) // Will separate the file into chunks of size 1100 bytes.
.Concurrent(true) // Will upload all files simultaneously.
.AutoRetryAfter(300) // Will attempt a failed chunk upload after 300ms.
.MaxAutoRetries(4) // Will attempt the same failed chunk upload 4 times.
)
)
C# code:
public void AppendToFile(string fullPath, Stream content)
{
try
{
using (FileStream stream = new FileStream(fullPath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
{
using (content)
{
content.CopyTo(stream);
}
}
}
catch (IOException ex)
{
throw ex;
}
}
public ActionResult ChunkSave(IEnumerable<HttpPostedFileBase> files, string metaData)
{
if (metaData == null)
{
return Save(files);
}
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(metaData));
var serializer = new DataContractJsonSerializer(typeof(ChunkMetaData));
ChunkMetaData chunkData = serializer.ReadObject(ms) as ChunkMetaData;
string path = String.Empty;
// The Name of the Upload component is "files"
if (files != null)
{
foreach (var file in files)
{
path = Path.Combine(Server.MapPath("~/App_Data"), chunkData.FileName);
AppendToFile(path, file.InputStream);
}
}
FileResult fileBlob = new FileResult();
fileBlob.uploaded = chunkData.TotalChunks - 1 <= chunkData.ChunkIndex;
fileBlob.fileUid = chunkData.UploadUid;
return Json(fileBlob);
}
public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
{
//The Name of the Upload component is "attachments".
foreach (var file in attachments)
{
//Some browsers send file names with a full path. You only care about the file name.
var fileName = Path.GetFileName(file.FileName);
var destinationPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
file.SaveAs(destinationPath);
}
//Return an empty string to signify success.
return Content("");
}
Can any one help me if I did something wrong?