取回多版本归档存储对象
更新时间: 2019-03-14 10:05
您可以通过ObsClient.RestoreObject接口传入版本号(VersionId)来取回多版本归档存储对象,示例代码如下:
- // 引入依赖包
- 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.RestoreObjectInput{}
- input.Bucket = "bucketname"
- input.Key = "objectkey"
- input.Days = 1
- input.Tier = obs.RestoreTierExpedited
- input.VersionId = "versionid"
- output, err := obsClient.RestoreObject(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)
- }
- }
父主题:多版本控制