huaweicloud / huaweicloud-sdk-go-obs

Apache License 2.0
42 stars 24 forks source link

CreateSignedUrlInput #29

Closed guihouchang closed 4 months ago

guihouchang commented 6 months ago

CreateSignedUrlInput 这个参数可以同ImageProgress的相关字段吗。我们现在需要对图片进行处理,发现没有提供相关的方法或字段,我们要怎么样才能达到处理图片的目的呢

liqiuqiu111 commented 4 months ago

这样试试,生效不! obsClient, err := obs.New(ak, sk, endPoint, obs.WithSignature(obs.SignatureObs))

if err != nil {
    fmt.Printf("Create obsClient error, errMsg: %s", err.Error())
}

// 生成下载对象的带授权信息的URL
getObjectInput := &obs.CreateSignedUrlInput{}
getObjectInput.Method = obs.HttpMethodGet
getObjectInput.Bucket = "your_bucketname"
getObjectInput.Key = "your_objectkey"

getObjectInput.Expires = 3600

getObjectInput.Headers = map[string]string{
    "x-obs-ImageProcess ": "image/resize,m_fixed,w_100,h_100/rotate,90",
}
// 生成下载对象的带授权信息的URL
getObjectOutput, err := obsClient.CreateSignedUrl(getObjectInput)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Printf("SignedUrl:%s\n", getObjectOutput.SignedUrl)
fmt.Printf("ActualSignedRequestHeaders:%v\n", getObjectOutput.ActualSignedRequestHeaders)