-
Notifications
You must be signed in to change notification settings - Fork 515
修复从 token 解析 bucket 的 bug & 完善下类型 & fix issue #456
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
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. 这个异常应该不重新 throw 出去吗? @nighca |
||
} | ||
|
||
public async putFile(): Promise<utils.ResponseSuccess<UploadCompleteData>> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,8 +272,9 @@ interface PutPolicy { | |
|
||
export function getPutPolicy(token: string) { | ||
const segments = token.split(':') | ||
const ak = segments[0] | ||
const putPolicy: PutPolicy = JSON.parse(urlSafeBase64Decode(segments[2])) | ||
// token 构造的差异参考:https://github.com/qbox/product/blob/master/kodo/auths/UpToken.md#admin-uptoken-authorization | ||
const ak = segments.length > 3 ? segments[1] : segments[0] | ||
const putPolicy: PutPolicy = JSON.parse(urlSafeBase64Decode(segments[segments.length - 1])) | ||
Comment on lines
+275
to
+277
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. @nighca = =… |
||
|
||
return { | ||
ak, | ||
|
Uh oh!
There was an error while loading. Please reload this page.