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
signURL 不能处理object key中包含/路径分隔符 #82
Comments
you should use url.QueryUnescape method |
感觉没必要在SignURL里面对key做url.QueryEscape吧,返回以后还是要url.QueryUnescape |
可否给个例子? 这是常见问题 |
|
这个问题是不考虑修复吗?目前还是会这样,SignUrl 得到的结果,把文件路径中的 |
I agree with the above comment (at least what Google translated it to). Why is My fix for this is to first Sign the URL and then run // Ask Aliyun library to sign the URL
aliurl, err := bucket.SignURL(file, "GET", 60*60)
if err != nil {
// notest
return "", err
}
// Parse the resulting URL
ur, err := url.Parse(aliurl)
if err != nil {
return "", err
}
// This bit fixes an unnecessary (and incorrect, IMHO) encoding performed by the
// Aliyun Go SDK.
epath, err := url.PathUnescape(ur.Path)
if err != nil {
return "", err
}
// Plug the correct path back into the URL
ur.Path = epath
ur.RawPath = epath
return ur.String(), nil But this shouldn't be necessary and it probably doesn't work for some problematic URLs (which I fortunately don't seem to have). |
如果object key中包含路径分隔符/,signURL会将/转换为%252F,导致返回的url无法使用。
The text was updated successfully, but these errors were encountered: