I'm need to implement next page:
User click on button Upload file, select file and uploading it on server. After uploading file will be processed by converter. Converter can return percentage of conversion. How to implement continuous progress bar on page (progress = upload progress + convert progress)?
I'm using PlUpload - this tool can return percentage of uploading file to server, but I can't override returning percentage.
That my upload action:
public ActionResult ConferenceAttachment(int? chunk, string name, Identity cid)
{
var fileUpload = Request.Files[0];
var tempfolder = Path.GetTempFileName().Replace('.', '-');
Directory.CreateDirectory(tempfolder);
var fn = Path.Combine(tempfolder, name);
chunk = chunk ?? 0;
using (var fs = new FileStream(fn, chunk == 0 ? FileMode.Create : FileMode.Append))
{
var buffer = new byte[fileUpload.InputStream.Length];
fileUpload.InputStream.Read(buffer, 0, buffer.Length);
fs.Write(buffer, 0, buffer.Length);
}
// CONVERTING ....
return Content("OK", "text/plain");
}
Which architecture solution can solve my problem? Or which JS upload library?
You must use some kind of Real-Time
connection or a Streaming
to do this.
1) Using SignalR you can create a Hub
to notificate the client about the progress, easy to implement and powerfull.
2) You can adapte this example about PushStreamContent
to send the progress while you are converting: