forked from mystiq/hydrogen-web
provide default mimetype so file uploads work on iOS
otherwise homeserverapi doesn't think this is a blob
This commit is contained in:
parent
6ad778d27b
commit
e603e4b455
1 changed files with 4 additions and 2 deletions
|
@ -69,6 +69,8 @@ const ALLOWED_BLOB_MIMETYPES = {
|
||||||
'audio/x-flac': true,
|
'audio/x-flac': true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const DEFAULT_MIMETYPE = 'application/octet-stream';
|
||||||
|
|
||||||
export class BlobHandle {
|
export class BlobHandle {
|
||||||
constructor(blob, buffer = null) {
|
constructor(blob, buffer = null) {
|
||||||
this._blob = blob;
|
this._blob = blob;
|
||||||
|
@ -79,7 +81,7 @@ export class BlobHandle {
|
||||||
static fromBuffer(buffer, mimetype) {
|
static fromBuffer(buffer, mimetype) {
|
||||||
mimetype = mimetype ? mimetype.split(";")[0].trim() : '';
|
mimetype = mimetype ? mimetype.split(";")[0].trim() : '';
|
||||||
if (!ALLOWED_BLOB_MIMETYPES[mimetype]) {
|
if (!ALLOWED_BLOB_MIMETYPES[mimetype]) {
|
||||||
mimetype = 'application/octet-stream';
|
mimetype = DEFAULT_MIMETYPE;
|
||||||
}
|
}
|
||||||
return new BlobHandle(new Blob([buffer], {type: mimetype}), buffer);
|
return new BlobHandle(new Blob([buffer], {type: mimetype}), buffer);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,7 @@ export class BlobHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
get mimeType() {
|
get mimeType() {
|
||||||
return this._blob.type;
|
return this._blob.type || DEFAULT_MIMETYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
|
|
Loading…
Reference in a new issue