From e603e4b45563b4c2098e65af94f2d59893c9f077 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 4 Mar 2021 21:51:53 +0100 Subject: [PATCH] provide default mimetype so file uploads work on iOS otherwise homeserverapi doesn't think this is a blob --- src/platform/web/dom/BlobHandle.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform/web/dom/BlobHandle.js b/src/platform/web/dom/BlobHandle.js index 92c875e7..b029555b 100644 --- a/src/platform/web/dom/BlobHandle.js +++ b/src/platform/web/dom/BlobHandle.js @@ -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() {