You can implement a server side progress function while uploading a file to the client in ASP.NET Core 7 Web API controller using the following steps:
public async Task<iactionresult> UploadFile(IFormFile file)
var totalBytes = file.Length; var uploadedBytes = 0L;
...
if (chunkedFile.Length > 0) { await fileStream.WriteAsync(chunkedFile, cancellationToken); uploadedBytes += chunkedFile.Length;
// Calculate progress percentage
var progress = Convert.ToInt32((uploadedBytes * 100) / totalBytes);
}
return Ok(progress);
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-03-02 11:00:00 +0000
Seen: 7 times
Last updated: Sep 29 '21
What is the process of authentication for tokens in Firebase Cloud Messaging?
How can mutual authentication be implemented on a development server for a Django web application?
What does receiving a 401 error from Netsuite REST API imply?
How can Google OAuth be integrated with FastAPI?
What is the method to only render components on the client side in NextJS 13?
How can the server update the Firebase ID token?
How can authorized API resources be utilized with a public client in Keycloak?