复制多版本对象
更新时间: 2019-03-14 10:05
您可以通过ObsClient.CopyObject接口传入版本号(CopySourceVersionId)来复制多版本对象,示例代码如下:
- // 引入依赖包
- import (
- "fmt"
- "obs"
- )
- var ak = "*** Provide your Access Key ***"
- var sk = "*** Provide your Secret Key ***"
- var endpoint = "https://your-endpoint"
- // 创建ObsClient结构体
- var obsClient, _ = obs.New(ak, sk, endpoint)
- func main() {
- input := &obs.CopyObjectInput{}
- input.Bucket = "destbucketname"
- input.Key = "destobjectkey"
- input.CopySourceBucket = "sourcebucketname"
- input.CopySourceKey = "sourceobjectkey"
- // 设置要复制对象的版本号
- input.CopySourceVersionId = "versionid"
- output, err := obsClient.CopyObject(input)
- if err == nil {
- fmt.Printf("RequestId:%s\n", output.RequestId)
- } else if obsError, ok := err.(obs.ObsError); ok {
- fmt.Printf("Code:%s\n", obsError.Code)
- fmt.Printf("Message:%s\n", obsError.Message)
- }
- }
父主题:多版本控制