From ef98b9a19b7f2c547fc56d26dad28364cc1923dc Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 19 Feb 2020 10:12:11 +0100 Subject: [PATCH] MOBILE-3344 fileuploader: Accept more types in isInvalidMimetype --- src/core/fileuploader/providers/fileuploader.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/fileuploader/providers/fileuploader.ts b/src/core/fileuploader/providers/fileuploader.ts index a061b8e29..d5c2fcda3 100644 --- a/src/core/fileuploader/providers/fileuploader.ts +++ b/src/core/fileuploader/providers/fileuploader.ts @@ -298,12 +298,18 @@ export class CoreFileUploaderProvider { * @return Undefined if file is valid, error message if file is invalid. */ isInvalidMimetype(mimetypes?: string[], path?: string, mimetype?: string): string { - let extension; + let extension: string; if (mimetypes) { // Verify that the mimetype of the file is supported. if (mimetype) { extension = this.mimeUtils.getExtension(mimetype); + + if (mimetypes.indexOf(mimetype) == -1) { + // Get the "main" mimetype of the extension. + // It's possible that the list of accepted mimetypes only includes the "main" mimetypes. + mimetype = this.mimeUtils.getMimeType(extension); + } } else { extension = this.mimeUtils.getFileExtension(path); mimetype = this.mimeUtils.getMimeType(extension);