开发者

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 pa开发者_StackOverflowrtially 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜