@@ -32,9 +32,14 @@ const readFile = function (file, resolve, reject) {
3232 this . readAsDataURL ( file ) ;
3333} ;
3434const findFileTypeMapping = ( mappings , file ) => mappings . find ( ( item ) => item . mimeTypes . find ( ( type ) => type === file . type ) ) ;
35+ const checkIsFileWithinMimeTypes = ( mimeTypes , file ) => ! ! mimeTypes . find ( ( type ) => type === file . type ) ;
3536const isMimeTypeAllowed = ( mappings , file ) => ! ! findFileTypeMapping ( mappings , file ) ;
3637
37- const checkFileTypeAllowed = ( file , locationMapping ) => ( ! locationMapping ? true : isMimeTypeAllowed ( locationMapping . mappings , file ) ) ;
38+ const checkFileTypeAllowed = ( file , locationMapping , config ) => {
39+ return ! locationMapping
40+ ? config . defaultMappings . some ( ( mapping ) => checkIsFileWithinMimeTypes ( mapping . mimeTypes , file ) )
41+ : isMimeTypeAllowed ( locationMapping . mappings , file ) ;
42+ } ;
3843
3944const detectContentTypeMapping = ( file , parentInfo , config ) => {
4045 const locationMapping = config . locationMappings . find ( ( item ) => item . contentTypeIdentifier === parentInfo . contentTypeIdentifier ) ;
@@ -262,7 +267,7 @@ export const checkCanUpload = (file, parentInfo, config, errorCallback) => {
262267 ) ;
263268 }
264269
265- if ( ! checkFileTypeAllowed ( file , locationMapping ) ) {
270+ if ( ! checkFileTypeAllowed ( file , locationMapping , config ) ) {
266271 errorMsgs . push ( Translator . trans ( /*@Desc ("File type is not allowed")*/ 'disallowed_type.message' , { } , 'ibexa_multi_file_upload' ) ) ;
267272 }
268273
0 commit comments