File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 5
5
setLocalFileInfo ,
6
6
removeLocalFileInfo ,
7
7
getLocalFileInfo ,
8
- isContainFileMimeType ,
8
+ findMimeType ,
9
9
sum ,
10
10
getDomainFromUrl ,
11
11
getPortFromUrl ,
@@ -65,11 +65,14 @@ export class UploadManager {
65
65
this . putExtra . fname = this . file . name ;
66
66
}
67
67
if ( this . putExtra . mimeType && this . putExtra . mimeType . length ) {
68
- if ( ! isContainFileMimeType ( this . file . type , this . putExtra . mimeType ) ) {
69
- let err = new Error ( "file type doesn't match with what you specify" ) ;
70
- this . onError ( err ) ;
71
- return ;
72
- }
68
+ var compareMimeType = findMimeType ( this . file . type , this . putExtra . mimeType ) ;
69
+ if ( compareMimeType == null || compareMimeType == undefined ) {
70
+ let err = new Error ( "file type doesn't match with what you specify" ) ;
71
+ this . onError ( err ) ;
72
+ return ;
73
+ } else {
74
+ this . putExtra . mimeType = [ compareMimeType ] ;
75
+ }
73
76
}
74
77
let upload = getUploadUrl ( this . config , this . token ) . then ( res => {
75
78
this . uploadUrl = res ;
Original file line number Diff line number Diff line change @@ -264,9 +264,10 @@ function getUpHosts(token) {
264
264
}
265
265
}
266
266
267
-
268
- export function isContainFileMimeType ( fileType , mimeType ) {
269
- return mimeType . indexOf ( fileType ) > - 1 ;
267
+ export function findMimeType ( fileType , mimeType ) {
268
+ return mimeType . find ( ( elem ) => {
269
+ return fileType == elem ;
270
+ } ) ;
270
271
}
271
272
272
273
export function createObjectURL ( file ) {
You can’t perform that action at this time.
0 commit comments