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?
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.
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:
Of course this could lead to the wrong file, but so can hashing.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With