Skip to content

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

Merged
merged 3 commits into from
Oct 12, 2019
Merged

repair mimeType #424

merged 3 commits into from
Oct 12, 2019

Conversation

JemyCheung
Copy link

repair mimeType

src/utils.js Outdated
rtType = fileType;
}
});
return rtType;
Copy link
Collaborator

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;
Copy link
Collaborator

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 返回回去

@bachue bachue merged commit 9becd29 into qiniu:master Oct 12, 2019
this.onError(err);
return;
} else {
this.putExtra.mimeType = [compareMimeType];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是因为这个吗? @JemyCheung

requestUrl += "/mimeType/" + urlSafeBase64Encode(putExtra.mimeType);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看这个 pr 应该是这样,采用当前文件的 mimeType,而不是名单里的都放到 url 里,不过也很奇怪,没见反应过这个问题,也可能是我遗漏了 @lzfee0227

Copy link
Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在这个接口的设计上
既然数组是白名单、null 是无限制
那空数组等同于 null 是不是不太好?
哪怕空数组没什么意义 @nighca

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的空数组是想表达的是无效的意思,主要是感觉这个不像权限那种需要从严控制,所以就等同 null,要是用户给了空数组是代表任何类型都不能上传的话,相当于多了些操作控制

Copy link
Contributor

@winddies winddies left a 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compareMimeType == null 就同时包含了 null 和 undefined

Copy link
Author

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];
Copy link
Contributor

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;
});
Copy link
Contributor

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) 就好了

Copy link
Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对了,你们是因为什么原因更新的?这个项目的更新是要经过我们这边的 review 的。。。我们也是突然发现你们提了这个 pr 并且已经 merged 了。。。。

@lzfee0227
Copy link
Collaborator

@winddies
现在处于 master 跟发的版本不匹配的状态
修复一下啊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants