简体   繁体   中英

Progress bar MVC 4 Save uploaded file to Database

I'm Writing application where I must upload CSV file to blob -azure cloud- then I show the file content to a user to get some configuration like Columns Names, types and select Columns to be Inserted into the database.

My Question : I get the file from the cloud as a stream I want make progress bar work while Saving to Database, any ideas about how to do that ?!

Thanks in Participation.

I tried using session variable and Ajax Jquery to read get the percentage but it is not working in debugging time.

In order to show the progress of an upload I would suggest using a third party library that has this functionality

Here is an example of such a plugin: http://blueimp.github.io/jQuery-File-Upload/ I've used this previously and it works well.

Concerning this:

I want make progress bar work while Saving to Database

I'm assuming this is a very big file, a small file of just a few thousand lines could probably be saved without the user noticing a delay (once it is uploaded) and you probably don't need to worry about showing a progress bar as it will be done almost instantly.

If this is not the case I would probably try to do something along the lines of the upload returning a unique ID to the client for the file they uploaded and then this id is used to make a separate AJAX query where you return the progress to the end user.

The idea would be

  1. Send file to server and show upload progress
  2. Store file in database
  3. return an Id in the file in the upload request
  4. As you read through the file store the progress of the process on the file in the database
  5. Make a separate interface available where you can post the id of a file and get the progress returned to you.
  6. Query this separate interface and display results.
  7. When file is completely processed, forward user to a View containing the results using Javascript

I used SignalR to update ProgressBar and it is Working Fine, check this link for More Information.

http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/introduction-to-signalr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM