1

The users for our software will want to upload potentially large amounts of files in bulk to our servers. It is then desired that we display the upload status any time the user views the upload screen. This doesn't have to be any more fancy than a progress bar with a percent status.

Our user will want to upload many files at once and to see the status of their upload.

My question is, how can I keep track of the uploaded files and return them at any possible time with a simple GET request at '/upload/status'.

A first solutions aims to keep track of the uploads requested and those processed in a database table. That way, it is as easy as querying the database any time the user wants to see his upload status.

the uploaded files are saved to a database

Is this a viable- and correct- solution to handling the state of file uploads in a REST service? Should I be looking for solutions elsewhere?

2
  • Are the uploads happening in a browser? Sep 16, 2013 at 14:38
  • @Mike Partridge: Yes they are.
    – IAE
    Sep 16, 2013 at 15:48

1 Answer 1

2

The approach you have described will work, as long as you have a mechanism for identifying who the user is making the request. e.g. /upload/status?uid=32343

Where this gets interesting is in how you return the information back to the user. You can make it a single hit, as you described. There are also possibilities based on redirect / refresh headers in the response as well.

However also consider using the mutli-part response. You receive the HTTP request and issue a multi-part response and send the first response immediately back to the client. you then maintain the connection and send additional partial responses back to the client every few seconds. you continue doing this until either the client closes the connection, or you identify that all the files have uploaded, at which point you send the last response finishing the multi-response HTTP response message to the client.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.