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

The expiration time of the generated pre-signed URL does not take effect #33

Open
xigua88-66 opened this issue Oct 29, 2024 · 1 comment

Comments

@xigua88-66
Copy link

When I generated the pre-signed URL, I set an expiration time, but the link expiration time did not take effect, and the expiration time in the link was incorrect.

go version: 1.22
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.24.9+incompatible

`func SignDownUrl(path string) {
client, err := NewHuaWeiObsClient()
if err != nil {
fmt.Println(err)
}
expires := 60
input := obs.CreateSignedUrlInput{
Bucket: "migrate-to-minio-test",
Key: path,
Method: obs.HttpMethodGet,
Expires: expires,
}

signedUrl, err := client.CreateSignedUrl(&input)
if err != nil {
	fmt.Println(err)
}
fmt.Println(signedUrl.SignedUrl)

}
`
The generated link is like: http://migrate-to-minio-test.obs.cn-north-4.myhuaweicloud.com:80/hudi-release-0.12.0.tar.gz?AWSAccessKeyId=GR6MO2GUCFAVCI&Expires=1730200189&Signature=G6czdPuWyvFoVsHerIYkLNw4TkM%3D

@liqiuqiu111
Copy link

endPoint := "https://obs.cn-north-4.myhuaweicloud.com"
// 创建obsClient实例
// 如果使用临时AKSK和SecurityToken访问OBS,需要在创建实例时通过obs.WithSecurityToken方法指定securityToken值。
obsClient, err := obs.New(ak, sk, endPoint/, obs.WithSecurityToken(securityToken)/)
if err != nil {
fmt.Printf("Create obsClient error, errMsg: %s", err.Error())
}
putObjectInput := &obs.CreateSignedUrlInput{}
putObjectInput.Method = obs.HttpMethodPut
putObjectInput.Bucket = "examplebucket"
putObjectInput.Key = "example/objectname"
putObjectInput.Expires = 3600
// 生成上传对象的带授权信息的URL
putObjectOutput, err := obsClient.CreateSignedUrl(putObjectInput)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("SignedUrl:%s\n", putObjectOutput.SignedUrl)
fmt.Printf("ActualSignedRequestHeaders:%v\n", putObjectOutput.ActualSignedRequestHeaders)

请按照官网demo,链接里的expires是通过服务器编译后的10位时间戳。

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

No branches or pull requests

2 participants