How to include Content-MD5 header in FineUploader Azure request?

▼魔方 西西 提交于 2019-12-10 10:36:46

问题


I would like to use the Content-MD5 header to supply Azure with a client-side generated MD5 hash of the files being uploaded. How would I accomplish this task in FineUploader?

Target audience: Firefox, Chrome, Safari, Opera and IE10+.

Judging by this answer I gather that it should be possible but at least half of our clients will run on very old (slow) computers. Is it feasible to do this client side MD5 hashing approach then?

Somewhat related side question: I was also thinking that it might be wise to set a maximum file size to reduce strain on the MD5 hashing algorithm. Maybe just below Azure's "chunking" limit? From a different view: Can I disable chunking?


回答1:


Fine Uploader provides direct access to the underlying File or Blob object via the getFile(id) API method. Once you have access to this, you can make use of FileReader to read the file/blob bytes and generate a hash. To make hashing even easier, consider using a JS library like SparkMD5.

The best place to calculate this hash is probably in an onSubmit callback handler. Since the process of reading a file is asynchronous, you will have to return a promise in your handler, which is supported by Fine Uploader. Once the hash has been calculated, resolve the promise and set the hash as a parameter for the file using Fine Uploader's setParams API method.

Can I disable chunking?

Yes, you can, but you will lose all of the benefits associated with chunking, along with the resume feature and efficient retries should the file upload fail midway though.



来源:https://stackoverflow.com/questions/29939610/how-to-include-content-md5-header-in-fineuploader-azure-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!