uploading a file and then, in the Chrome browser, in the Network pane, change the uploading speed to a very minimum, then submit the form and then immediately close the browser.uploading a big file(about 16MB) and then suddenly after submitting the HTML form immediately close the browser window.To produce such an issue/edge case I tried: My idea was to count the file size at the point where the file is uploaded, add the information about the file size as an extra HTTP-HEADER (I called it Complete-File-Size), and then when the request reaches the backend, count if the received file size is exactly the same as the Complete-File-Size. I'm trying to prevent an edge case when somebody performs a POST request against my API UploadAppraisalFile endpoint and suddenly loses an internet connection which would result in sending a request with not the full file content. Return StatusCode(StatusCodes.Status411LengthRequired, "Complete-File-Size header doesn't much received byteArray size") Logger.LogDebug("Complete-File-Size header doesn't much received byteArray size", file.Length, completeFileSize, inputAsString) Var inputAsString = Convert.ToBase64String(stream.ToArray()) If (file = null || file.Length != completeFileSize) Int.TryParse(completeFileSizeHeader, out int completeFileSize) Var completeFileSizeHeader = Request.Headers intermitent code change to investigate and validate Complete File Size and Actual File Size Public async Task UploadAppraisalFile(int appraisalID, string fileSubjectCode, IFormFile file)įile = file ?.FirstOrDefault() Please try to upload images/videos of a specific aspect ratio File upload *Only PDF, MP4, WEBM, OGG, JPG, JPEG, & PNG files are allowed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |