Skip to content

Commit

Permalink
fix(android): fix Ti.Blob.arrayBuffer definition
Browse files Browse the repository at this point in the history
still broken on iOS. May need to implement natively
  • Loading branch information
sgtcoolguy committed Aug 31, 2020
1 parent fcb99d1 commit 8fde716
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions common/Resources/ti.internal/extensions/ti/ti.blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
*/
const buffer = Ti.createBuffer({ value: '' });
const blob = buffer.toBlob();
const BlobPrototype = Object.getPrototypeOf(blob);
// FIXME: This doesn't "stick" for iOS. Probably need to implement it natively.
// Web Blob has an arrayBuffer() method that returns a Promise
// https://developer.mozilla.org/en-US/docs/Web/API/Blob/arrayBuffer
blob.constructor.prototype.arrayBuffer = function () {
return new Promise((resolve, reject) => {
let buf;
try {
buf = this.toArrayBuffer();
} catch (err) {
return reject(err);
}
resolve(buf);
});
};
Object.defineProperty(BlobPrototype, 'arrayBuffer', {
value: function () {
return new Promise((resolve, reject) => {
let buf;
try {
buf = this.toArrayBuffer();
} catch (err) {
return reject(err);
}
resolve(buf);
});
},
enumerable: true
});

0 comments on commit 8fde716

Please sign in to comment.