Skip to content
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

修复从 token 解析 bucket 的 bug & 完善下类型 & fix issue #456

Merged
merged 5 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "qiniu-js",
"jsName": "qiniu",
"version": "3.0.2",
"version": "3.0.3",
"private": false,
"description": "Javascript SDK for Qiniu Resource (Cloud) Storage AP",
"main": "lib/index.js",
Expand Down
7 changes: 5 additions & 2 deletions src/upload/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ export default abstract class Base {
this.onData = handlers.onData
this.onError = handlers.onError
this.onComplete = handlers.onComplete

this.bucket = utils.getPutPolicy(this.token).bucket
try {
this.bucket = utils.getPutPolicy(this.token).bucket
} catch (e) {
this.onError(e)
}
Comment on lines +131 to +133
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个异常应该不重新 throw 出去吗? @nighca

}

public async putFile(): Promise<utils.ResponseSuccess<UploadCompleteData>> {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ interface PutPolicy {
export function getPutPolicy(token: string) {
const segments = token.split(':')
const ak = segments[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

check

Copy link
Collaborator

Choose a reason for hiding this comment

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

要不要写一下文档链接或格式注释

const putPolicy: PutPolicy = JSON.parse(urlSafeBase64Decode(segments[2]))
const putPolicy: PutPolicy = JSON.parse(urlSafeBase64Decode(segments[segments.length - 1]))

return {
ak,
Expand Down