-
Notifications
You must be signed in to change notification settings - Fork 515
repair mimeType #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repair mimeType #424
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -5,7 +5,7 @@ import { | |||
setLocalFileInfo, | ||||
removeLocalFileInfo, | ||||
getLocalFileInfo, | ||||
isContainFileMimeType, | ||||
findMimeType, | ||||
sum, | ||||
getDomainFromUrl, | ||||
getPortFromUrl, | ||||
|
@@ -65,11 +65,14 @@ export class UploadManager { | |||
this.putExtra.fname = this.file.name; | ||||
} | ||||
if (this.putExtra.mimeType && this.putExtra.mimeType.length) { | ||||
if (!isContainFileMimeType(this.file.type, this.putExtra.mimeType)){ | ||||
let err = new Error("file type doesn't match with what you specify"); | ||||
this.onError(err); | ||||
return; | ||||
} | ||||
var compareMimeType = findMimeType(this.file.type, this.putExtra.mimeType); | ||||
if (compareMimeType == null || compareMimeType == undefined) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. compareMimeType == null 就同时包含了 null 和 undefined There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 嗯嗯,是的,find() return结果某些情况下我看有打印null也有undefined,就都加上了,第一次pr是没加undefined |
||||
let err = new Error("file type doesn't match with what you specify"); | ||||
this.onError(err); | ||||
return; | ||||
} else { | ||||
this.putExtra.mimeType = [compareMimeType]; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是因为这个吗? @JemyCheung Line 89 in c0f5845
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 看这个 pr 应该是这样,采用当前文件的 mimeType,而不是名单里的都放到 url 里,不过也很奇怪,没见反应过这个问题,也可能是我遗漏了 @lzfee0227 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 工单和群里用户反馈mimeType数组所有类型全部上传到后台了,经测试是这样 @lzfee0227 |
||||
} | ||||
} | ||||
let upload = getUploadUrl(this.config, this.token).then(res => { | ||||
this.uploadUrl = res; | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,9 +264,10 @@ function getUpHosts(token) { | |
} | ||
} | ||
|
||
|
||
export function isContainFileMimeType(fileType, mimeType){ | ||
return mimeType.indexOf(fileType) > -1; | ||
export function findMimeType(fileType, mimeType) { | ||
return mimeType.find((elem) => { | ||
return fileType == elem; | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里应该用三等,而且这个直接 return mimeType.find(type => fileType === type) 就好了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 谢谢,确实,我没有掌握三等这个写法 @winddies 我下午已经更新去掉了find的用法,经过测试find在IE内核不兼容,采用了forEach There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 对了,你们是因为什么原因更新的?这个项目的更新是要经过我们这边的 review 的。。。我们也是突然发现你们提了这个 pr 并且已经 merged 了。。。。 |
||
} | ||
|
||
export function createObjectURL(file) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在这个接口的设计上
既然数组是白名单、null 是无限制
那空数组等同于 null 是不是不太好?
哪怕空数组没什么意义 @nighca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的空数组是想表达的是无效的意思,主要是感觉这个不像权限那种需要从严控制,所以就等同 null,要是用户给了空数组是代表任何类型都不能上传的话,相当于多了些操作控制