I try to create a Blob object and pass an Uint8Array to it’s constructor It works fine on chrome and firefox on windows In chrome and safari on ios however the Blod does not contain the data of the Uint8Array but the text : [object Uint8Array]
I need this to upload a canvas to the server.
Is there a workaround?
I'm struggling with the exact same problem. When I backup the Uint8Array with an ArrayBuffer, it does work in both Safari and Chrome (not tested in other browsers yet) but Chrome prints a warning message. Chrome says I have to wrap ArrayBuffer in a DataView before passing it to Blob() constructor.
// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
new Blob([ab], {type: mimeString});
Edit
The exact Chrome deprecation message is:
ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead.
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