PUT Object - Copy
API Description
You can use this API to create a copy for an object in a specified bucket.
Method Definition
func (obsClient ObsClient) CopyObject(input *CopyObjectInput) (output *CopyObjectOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) CopyObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *CopyObjectOutput, err error)
Request Parameter
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() {
input := &obs.CopyObjectInput{}
input.Bucket = "bucketname"
input.Key = "objectkey"
input.CopySourceBucket = "sourcebucketname"
input.CopySourceKey = "sourceobjectkey"
output, err := obsClient.CopyObject(input)
if err == nil {
fmt.Printf("RequestId:%s\n", output.RequestId)
fmt.Printf("ETag:%s, LastModified:%s\n",
output.ETag, output.LastModified)
} else {
if obsError, ok := err.(obs.ObsError); ok {
fmt.Println(obsError.Code)
fmt.Println(obsError.Message)
} else {
fmt.Println(err)
}
}
} Last Article: GET Object
Next Article: DELETE Object
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.