Good afternoon,
I'm using a chunk upload to upload files, some of which could be greater than 2GB.
When the user has selected a file I want to run a series of checks of the filename against a database before deciding whether to allow the upload to take place. If it fails that validation I want it to return a message to the view explaining why it failed.
I've set the Upload as follows:
@(Html.Kendo().Upload()
.Name("files")
.HtmlAttributes(new { aria_label = "files"})
.Enable(true)
.Multiple(false)
.Async(a => a
.Save("Async_ChunkSave", "Source")
.Remove("Async_Remove", "Source")
.AutoUpload(true)
.ChunkSize(4194304)
)
.Events(events => events
.Upload("onUpload")
.Complete("onComplete")
.Error("onUploadError"))
)
I'm using the Upload event to send some extra data from the view:
public async Task<ActionResult> Async_ChunkSaveAsync(IEnumerable<IFormFile> files, string metaData, string uploadData)
Am I right in thinking that although it has a foreach file in files, it will only be one file since chunkData.FileName can only be one file - presumably the same name as the file's.
if (files != null)
{
foreach (var file in files)
{
path = Path.Combine(fullFolderPath, chunkData.FileName);
AppendToFile(path, file);
}
}
Where is the best place to validate the filename against the database, before it starts handling some potentially very large files? And then return an appropriate error message to the View, and halt the upload?
Kind regards,
Richard