mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
rename blob.blob to blob.nativeBlob
also to make the name a bit more unique where we want to do duck typing
This commit is contained in:
parent
2cfffa015d
commit
c278b0f4a3
@ -137,9 +137,9 @@ export class Platform {
|
|||||||
|
|
||||||
saveFileAs(blobHandle, filename) {
|
saveFileAs(blobHandle, filename) {
|
||||||
if (navigator.msSaveBlob) {
|
if (navigator.msSaveBlob) {
|
||||||
navigator.msSaveBlob(blobHandle.blob, filename);
|
navigator.msSaveBlob(blobHandle.nativeBlob, filename);
|
||||||
} else {
|
} else {
|
||||||
downloadInIframe(this._container, this._paths.downloadSandbox, blobHandle.blob, filename);
|
downloadInIframe(this._container, this._paths.downloadSandbox, blobHandle.nativeBlob, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ const ALLOWED_BLOB_MIMETYPES = {
|
|||||||
|
|
||||||
export class BlobHandle {
|
export class BlobHandle {
|
||||||
constructor(blob, buffer = null) {
|
constructor(blob, buffer = null) {
|
||||||
this.blob = blob;
|
this._blob = blob;
|
||||||
this._buffer = buffer;
|
this._buffer = buffer;
|
||||||
this._url = null;
|
this._url = null;
|
||||||
}
|
}
|
||||||
@ -89,6 +89,10 @@ export class BlobHandle {
|
|||||||
return new BlobHandle(file);
|
return new BlobHandle(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get nativeBlob() {
|
||||||
|
return this._blob;
|
||||||
|
}
|
||||||
|
|
||||||
async readAsBuffer() {
|
async readAsBuffer() {
|
||||||
if (this._buffer) {
|
if (this._buffer) {
|
||||||
return this._buffer;
|
return this._buffer;
|
||||||
@ -98,7 +102,7 @@ export class BlobHandle {
|
|||||||
reader.addEventListener("load", evt => resolve(evt.target.result));
|
reader.addEventListener("load", evt => resolve(evt.target.result));
|
||||||
reader.addEventListener("error", evt => reject(evt.target.error));
|
reader.addEventListener("error", evt => reject(evt.target.error));
|
||||||
});
|
});
|
||||||
reader.readAsArrayBuffer(this.blob);
|
reader.readAsArrayBuffer(this._blob);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,24 +116,24 @@ export class BlobHandle {
|
|||||||
reader.addEventListener("load", evt => resolve(evt.target.result));
|
reader.addEventListener("load", evt => resolve(evt.target.result));
|
||||||
reader.addEventListener("error", evt => reject(evt.target.error));
|
reader.addEventListener("error", evt => reject(evt.target.error));
|
||||||
});
|
});
|
||||||
reader.readAsText(this.blob, "utf-8");
|
reader.readAsText(this._blob, "utf-8");
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get url() {
|
get url() {
|
||||||
if (!this._url) {
|
if (!this._url) {
|
||||||
this._url = URL.createObjectURL(this.blob);
|
this._url = URL.createObjectURL(this._blob);
|
||||||
}
|
}
|
||||||
return this._url;
|
return this._url;
|
||||||
}
|
}
|
||||||
|
|
||||||
get size() {
|
get size() {
|
||||||
return this.blob.size;
|
return this._blob.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
get mimeType() {
|
get mimeType() {
|
||||||
return this.blob.type;
|
return this._blob.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
|
Loading…
Reference in New Issue
Block a user