Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resumable uploads using HTML5 File Upload API -

I want to implement resumable uploads with Html5, and everything seems to work, except identifying that the file to be uploaded is the same one already partially uploaded. Ideally, I would have some client side hashing of the file that generates unique id - however I could not find any working implementation of it and it seems too slow for large files (like I am dealing with).

Next, I thought about using the path to the file as the unique identifier, but I didn't see any way to get it from the API. file name, even considering file name per user can't be unique because users tend to have common names for files. Anyone can think of a solution for this?

like image 658
Yuval Avatar asked Jul 27 '11 17:07

Yuval


People also ask

How does Resumable js work?

Resumable. js is a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API . The library is designed to introduce fault-tolerance into the upload of large files through HTTP. This is done by splitting each file into small chunks.


2 Answers

I guess you best choice is some simple hashing (MD5 is properly too slow on large files to useful).

An alternative: Name the uploads by the file name (and some kind of running numbering when multiple files with the same name is uploaded, e.g. file-1, file-2, file-3), and check random bytes in the already uploaded file and the local file. For example:

  1. Find all files with the same filename (excluding the running numerical numbering)
  2. Compare 10 bytes every 10 MB from the server with the local file, if these bytes match you may feel confident enough about this being the right file.

Of course this could lead to the wrong file, but so can hashing.

like image 132
zpon Avatar answered Oct 09 '22 13:10

zpon


As mentioned in How to resume a paused or broken file upload at Mozilla Hacks, perhaps you can store the file in the browser using IndexedDB so that you can resume the upload without needing the user to reselect the file.

For a tutorial on how to storing files with IndexedDB, see Storing images and files in IndexedDB.

like image 1
Jeffery To Avatar answered Oct 09 '22 14:10

Jeffery To