I am using ChunkUpload of KendoUI Jquery, MVC , I think I need to rename the file before it enters the controller(ChunkSave) but I dont know which part of the process I am able to do that.
My reference for chunk upload: https://demos.telerik.com/kendo-ui/upload/chunkupload?_ga=2.247157956.1737132689.1612402138-1671290078.1573535372
here's my script
$(".fUploadSingle").kendoUpload({
async: {
chunkSize: 10000000,
saveUrl: '@Url.Action("ChunkSave", "Streaming", new { area = "" })',
removeUrl: "remove",
autoUpload: true
}
});
Controller:
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 somemetaData = 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("~/Videos/Materials"), somemetaData.FileName);
AppendToFile(path, file.InputStream);
}
}
FileResult fileBlob = new FileResult();
fileBlob.uploaded = somemetaData.TotalChunks - 1 <= somemetaData.ChunkIndex;
fileBlob.fileUid = somemetaData.UploadUid;
return Json(fileBlob);
}
question from:
https://stackoverflow.com/questions/66056214/how-to-rename-file-if-exist-using-kendoupload 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…