-
Notifications
You must be signed in to change notification settings - Fork 189
Upload with uptoken and stream #31
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
Conversation
lib/rs.js
Outdated
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.
为什么有 key、filename,两者有啥不同?传 filename 目的是啥?
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.
这里 multipart/form-data 上传的时候使用了 formstream 这个包:https://github.com/fengmk2/formstream ,上传 stream 的时候需要用到 filename:https://github.com/fengmk2/formstream/blob/master/lib/formstream.js#L134 。key 用于上传的时候组装"action"中的"EncodedEntryURI": http://docs.qiniutek.com/v3/api/io/#upload-file-by-multipart
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.
通常而言,key 里面应该就有 filename 呀。比如 key 是 foo/bar.jpg,那么 filename 可能就取 bar.jpg
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.
fd 不需要 close 么?
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.
需要。我加上。
lib/util.js
Outdated
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.
参数同时具备 crc32 + enableCrc32Check 的语义,叫 enableCrc32Check 很奇怪,应该是叫 crc32 会比较好。因为 enableCrc32Check == false 只是 crc32 的一个特殊值。
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.
已更新。这里确实应该改成 crc32 值,rs.uploadWithToken() 这个函数接收的也是一个 crc32 值。但是 rs.uploadFileWithToken() 这个函数接收的就是一个判断是否开启crc32校验的enableCrc32Check值,因为它自身可以从传入的文件来计算它的crc32值。
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.
需了解些 nodejs 的报错惯例。
No description provided.