mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
Add fallback to BlobBuilder API when Blob constructor is missing
This commit is contained in:
parent
4e6badc548
commit
2ed09bade2
@ -96,8 +96,25 @@ ImageJob.prototype = {
|
||||
headers: this.ajaxHeaders,
|
||||
responseType: "arraybuffer",
|
||||
success: function(request) {
|
||||
// Make the raw data into a blob
|
||||
var blb = new window.Blob([request.response]);
|
||||
var blb;
|
||||
// Make the raw data into a blob.
|
||||
// BlobBuilder fallback adapted from
|
||||
// http://stackoverflow.com/questions/15293694/blob-constructor-browser-compatibility
|
||||
try {
|
||||
blb = new window.Blob([request.response]);
|
||||
} catch (e) {
|
||||
var BlobBuilder = (
|
||||
window.BlobBuilder ||
|
||||
window.WebKitBlobBuilder ||
|
||||
window.MozBlobBuilder ||
|
||||
window.MSBlobBuilder
|
||||
);
|
||||
if (e.name === 'TypeError' && BlobBuilder) {
|
||||
var bb = new BlobBuilder();
|
||||
bb.append(request.response);
|
||||
blb = bb.getBlob();
|
||||
}
|
||||
}
|
||||
// If the blob is empty for some reason consider the image load a failure.
|
||||
if (blb.size === 0) {
|
||||
self.errorMsg = "Empty image response.";
|
||||
|
Loading…
Reference in New Issue
Block a user