Skip to content

Commit f34dae0

Browse files
author
JemyCheung
committed
repair mimeType
1 parent 7e07e59 commit f34dae0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/upload.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ export class UploadManager {
6565
this.putExtra.fname = this.file.name;
6666
}
6767
if (this.putExtra.mimeType && this.putExtra.mimeType.length) {
68-
if (!isContainFileMimeType(this.file.type, this.putExtra.mimeType)){
68+
var compareMimeType = isContainFileMimeType(this.file.type, this.putExtra.mimeType);
69+
if (compareMimeType == null){
6970
let err = new Error("file type doesn't match with what you specify");
7071
this.onError(err);
7172
return;
73+
}else{
74+
this.putExtra.mimeType = [compareMimeType];
7275
}
7376
}
7477
let upload = getUploadUrl(this.config, this.token).then(res => {

src/utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,13 @@ function getUpHosts(token) {
266266

267267

268268
export function isContainFileMimeType(fileType, mimeType){
269-
return mimeType.indexOf(fileType) > -1;
269+
var rtType = null;
270+
mimeType.forEach(elem => {
271+
if(fileType == elem){
272+
rtType = fileType;
273+
}
274+
});
275+
return rtType;
270276
}
271277

272278
export function createObjectURL(file) {

0 commit comments

Comments
 (0)