You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
865 B

  1. package main
  2. import (
  3. "context"
  4. "net/http"
  5. "net/url"
  6. "os"
  7. "github.com/tencentyun/cos-go-sdk-v5"
  8. "github.com/tencentyun/cos-go-sdk-v5/debug"
  9. )
  10. func main() {
  11. u, _ := url.Parse("https://test-1253846586.cos.ap-guangzhou.myqcloud.com")
  12. b := &cos.BaseURL{BucketURL: u}
  13. c := cos.NewClient(b, &http.Client{
  14. Transport: &cos.AuthorizationTransport{
  15. SecretID: os.Getenv("COS_SECRETID"),
  16. SecretKey: os.Getenv("COS_SECRETKEY"),
  17. Transport: &debug.DebugRequestTransport{
  18. RequestHeader: true,
  19. RequestBody: true,
  20. ResponseHeader: true,
  21. ResponseBody: true,
  22. },
  23. },
  24. })
  25. opt := &cos.ObjectRestoreOptions{
  26. Days: 2,
  27. Tier: &cos.CASJobParameters{
  28. // Standard, Exepdited and Bulk
  29. Tier: "Expedited",
  30. },
  31. }
  32. name := "archivetest"
  33. _, err := c.Object.PostRestore(context.Background(), name, opt)
  34. if err != nil {
  35. panic(err)
  36. }
  37. }