如何在FineUploader Azure请求中包含Content-MD5标头? [英] How to include Content-MD5 header in FineUploader Azure request?

查看:113
本文介绍了如何在FineUploader Azure请求中包含Content-MD5标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Content-MD5标头为Azure提供要客户端上传的文件的MD5哈希值.我将如何在FineUploader中完成此任务?

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?

目标受众:Firefox,Chrome,Safari,Opera和IE10 +.

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

根据此答案判断,我认为应该有可能,但至少有一半的客户将使用很老的软件(慢)计算机.那么采用这种客户端MD5哈希方法是否可行?

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?

一些相关的副问题:我还认为设置最大文件大小以减少对MD5哈希算法的压力可能是明智的.也许刚好低于Azure的分块"限制?从另一个角度来看:我可以禁用分块吗?

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?

推荐答案

Fine Uploader通过 SparkMD5 这样的JS库.

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.

计算此哈希值的最佳位置可能是在 onSubmit回调处理程序.由于读取文件的过程是异步的,因此您将必须在处理程序中返回一个promise,Fine Uploader支持该承诺.计算完哈希值后,请解析承诺并使用精细上传器的setParams API方法.

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.

这篇关于如何在FineUploader Azure请求中包含Content-MD5标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆