1

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?

4
  • Do you really use chunking feature of plupload ? (is a 30mb file uploaded in say 60 chunks of 500kb ?) If so, when does the conversion happen ? Upon receiving each chunk ? If so, your code seems fine, and just return a json result like this {"jsonrpc" : "2.0", "result" : null} Commented Oct 23, 2013 at 13:59
  • I need to compose single progress bar from progress of uploading and progress of converting. At first all file uploads, then converting. Commented Oct 23, 2013 at 14:02
  • do you really need the whole file to start your conversion ? Commented Oct 23, 2013 at 15:06
  • Yes, as I sad before. Commented Oct 24, 2013 at 8:06

2 Answers 2

4

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.

Learn About ASP.NET SignalR

2) You can adapte this example about PushStreamContent to send the progress while you are converting:

Asynchronously streaming video with ASP.NET Web API

Sign up to request clarification or add additional context in comments.

Comments

0

You can set buffer size as much as you want. But, I would say to upload 8kb data of file at a time & meanwhile start streaming conversion process asynchronously. But, for smooth progress again what kind of file you wanna upload?

2 Comments

Different files (from 10kb to 30 mb). Converting can take from 1 sec to 5 minutes.
I think what I said earlier may work properly in your case. But might be different in video,etc. files conversions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.