MOBILE-3344 fileuploader: Accept more types in isInvalidMimetype

main
Dani Palou 2020-02-19 10:12:11 +01:00
parent 4e987794c4
commit ef98b9a19b
1 changed files with 7 additions and 1 deletions

View File

@ -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);