-
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
Conversation
src/utils.js
Outdated
rtType = fileType; | ||
} | ||
}); | ||
return rtType; |
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.
@JemyCheung 这个其实可以考虑用 Array.find()
,不用 forEach
这种原始的实现方法。 此外,返回值以前是 bool,所以方法名称叫 isContainFileMimeType
,一旦搞成 find
,方法名就应该叫 findMimeType
src/utils.js
Outdated
export function findMimeType(fileType, mimeType) { | ||
return mimeType.find((elem) => { | ||
if (fileType == elem) { | ||
return elem; |
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.
@JemyCheung 你对 find()
的用法是错误的,应该是 mimeType.find((elem) => { return elem == fileType; })
只要返回 true 就表示找到了,不必把 elem
返回回去
this.onError(err); | ||
return; | ||
} else { | ||
this.putExtra.mimeType = [compareMimeType]; |
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.
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.
是因为这个吗? @JemyCheung
Line 89 in c0f5845
requestUrl += "/mimeType/" + urlSafeBase64Encode(putExtra.mimeType); |
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.
看这个 pr 应该是这样,采用当前文件的 mimeType,而不是名单里的都放到 url 里,不过也很奇怪,没见反应过这个问题,也可能是我遗漏了 @lzfee0227
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.
工单和群里用户反馈mimeType数组所有类型全部上传到后台了,经测试是这样 @lzfee0227
@@ -65,11 +65,14 @@ export class UploadManager { | |||
this.putExtra.fname = this.file.name; | |||
} | |||
if (this.putExtra.mimeType && this.putExtra.mimeType.length) { |
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,要是用户给了空数组是代表任何类型都不能上传的话,相当于多了些操作控制
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.
@nighca 浏览了下目前的 github 上的 issue, 目前没有这方面的 issue 到我这里来,这个可能是用户提工单或者其他开发同事开发过程中遇到的问题
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯,是的,find() return结果某些情况下我看有打印null也有undefined,就都加上了,第一次pr是没加undefined
this.onError(err); | ||
return; | ||
} else { | ||
this.putExtra.mimeType = [compareMimeType]; |
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.
看这个 pr 应该是这样,采用当前文件的 mimeType,而不是名单里的都放到 url 里,不过也很奇怪,没见反应过这个问题,也可能是我遗漏了 @lzfee0227
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
对了,你们是因为什么原因更新的?这个项目的更新是要经过我们这边的 review 的。。。我们也是突然发现你们提了这个 pr 并且已经 merged 了。。。。
@winddies |
repair mimeType