Creating a Signed URL
API Description
You can use this API to generate a signed URL whose Query parameters are carried with authentication information, by specifying the AK and SK, HTTP method, and request parameters. A signed URL allows you to perform specific operations on OBS.
Method Definition
func (obsClient ObsClient) CreateSignedUrl(input *CreateSignedUrlInput) (output *CreateSignedUrlOutput, err error)
Request Parameter
Field |
Type |
Optional or Mandatory |
---|---|---|
input |
Mandatory |
Returned Result
Field |
Type |
---|---|
output |
|
err |
error |
Sample Code
func main() { // Generate a signed URL for uploading an object. putObjectInput := &obs.CreateSignedUrlInput{} putObjectInput.Method = obs.HttpMethodPut putObjectInput.Bucket = "bucketname" putObjectInput.Key = "objectkey" putObjectInput.Expires = 3600 putObjectOutput, err := obsClient.CreateSignedUrl(putObjectInput) if err == nil { fmt.Printf("SignedUrl:%s\n", putObjectOutput.SignedUrl) fmt.Printf("ActualSignedRequestHeaders:%v\n", putObjectOutput.ActualSignedRequestHeaders) } else { fmt.Println(err) } // Generate a signed URL for downloading an object. getObjectInput := &obs.CreateSignedUrlInput{} getObjectInput.Method = obs.HttpMethodGet getObjectInput.Bucket = "bucketname" getObjectInput.Key = "objectkey" getObjectInput.Expires = 3600 getObjectOutput, err := obsClient.CreateSignedUrl(getObjectInput) if err == nil { fmt.Printf("SignedUrl:%s\n", getObjectOutput.SignedUrl) fmt.Printf("ActualSignedRequestHeaders:%v\n", getObjectOutput.ActualSignedRequestHeaders) } else { fmt.Println(err) } // Generate a signed URL for deleting an object. deleteObjectInput := &obs.CreateSignedUrlInput{} deleteObjectInput.Method = obs.HttpMethodDelete deleteObjectInput.Bucket = "bucketname" deleteObjectInput.Key = "objectkey" deleteObjectInput.Expires = 3600 deleteObjectOutput, err := obsClient.CreateSignedUrl(deleteObjectInput) if err == nil { fmt.Printf("SignedUrl:%s\n", deleteObjectOutput.SignedUrl) fmt.Printf("ActualSignedRequestHeaders:%v\n", deleteObjectOutput.ActualSignedRequestHeaders) } else { fmt.Println(err) } }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot