I am developping an application where I recieve image data stored in a uint8Array.
I then transform this data to a Blob and then build the image url.
Simplified code to get data from server:
var array;
var req = new XMLHttpRequest();
var url = "img/" + uuid + "_" +segmentNumber+".jpg";
req.open("GET", url, true);
req.responseType = "arraybuffer";
req.onload = function(oEvent) {
var data = req.response;
array = new Int8Array(data);
};
Constructor:
out = new Blob([data], {type : datatype} );
The Blob contsructor is causing problem. It works fine on all browsers except Chrome on mobile and desktop devices.
Use of Blob:
// Receive Uint8Array using AJAX here
// array = ...
// Create BLOB
var jpeg = new Blob( [array.buffer], {type : "image/jpeg"});
var url = DOMURL.createObjectURL(jpeg);
img.src = url;
Desktop Chrome gives me a warnning : ArrayBuffer values are deprecated in Blob Constructor. Use ArrayBufferView instead.
Mobile Chrome gives me an error: illegal constructor
If I change the constructor to work on Chrome it fails on other browsers.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…