问题描述
W3宣布他们打算废弃,优先使用新的如果我已经在使用BlobBuilder在JavaScript应用程序中,我该如何转换为使用这个新的Blob API?旧的WebKitBlobBuilder仍然可以在最新的WebKit(和Chrome Canary)中使用,但它很快就会被删除。在你写这样的东西之前:
var bb = new BlobBuilder();
bb.append(arrayBuffer);
var blob = bb.getBlob(mimeString);
如何使用新的Blob构造函数重写它?谢谢。
var dataView = new DataView(arrayBuffer);
var blob = new Blob([dataView],{type:mimeString});
The W3 announced that they intend to deprecate the BlobBuilder API in preference for the new Blob API.
If I am already using BlobBuilder in a JavaScript app, how can I convert to using this new Blob API? The old WebKitBlobBuilder is still available in the latest WebKit (and Chrome Canary), but it will soon be removed. Before you could write something like this:
var bb = new BlobBuilder();
bb.append(arrayBuffer);
var blob = bb.getBlob(mimeString);
How could this be rewritten to use the new Blob constructor? Thank you.
Passing an ArrayBuffer to the Blob constructor appears to be deprecated, so:
var dataView = new DataView(arrayBuffer);
var blob = new Blob([dataView], { type: mimeString });
这篇关于BlobBuilder和新的Blob构造函数有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!