mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
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
@ -69,6 +69,8 @@ const ALLOWED_BLOB_MIMETYPES = {
|
||||
'audio/x-flac': true,
|
||||
};
|
||||
|
||||
const DEFAULT_MIMETYPE = 'application/octet-stream';
|
||||
|
||||
export class BlobHandle {
|
||||
constructor(blob, buffer = null) {
|
||||
this._blob = blob;
|
||||
@ -79,7 +81,7 @@ export class BlobHandle {
|
||||
static fromBuffer(buffer, mimetype) {
|
||||
mimetype = mimetype ? mimetype.split(";")[0].trim() : '';
|
||||
if (!ALLOWED_BLOB_MIMETYPES[mimetype]) {
|
||||
mimetype = 'application/octet-stream';
|
||||
mimetype = DEFAULT_MIMETYPE;
|
||||
}
|
||||
return new BlobHandle(new Blob([buffer], {type: mimetype}), buffer);
|
||||
}
|
||||
@ -119,7 +121,7 @@ export class BlobHandle {
|
||||
}
|
||||
|
||||
get mimeType() {
|
||||
return this._blob.type;
|
||||
return this._blob.type || DEFAULT_MIMETYPE;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
Loading…
Reference in New Issue
Block a user