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.

40 lines
845 B

  1. package main
  2. import (
  3. "context"
  4. "fmt"
  5. "net/url"
  6. "os"
  7. "net/http"
  8. "github.com/tencentyun/cos-go-sdk-v5"
  9. "github.com/tencentyun/cos-go-sdk-v5/debug"
  10. )
  11. func main() {
  12. u, _ := url.Parse("https://test-1253846586.cos.ap-guangzhou.myqcloud.com")
  13. b := &cos.BaseURL{BucketURL: u}
  14. c := cos.NewClient(b, &http.Client{
  15. Transport: &cos.AuthorizationTransport{
  16. SecretID: os.Getenv("COS_SECRETID"),
  17. SecretKey: os.Getenv("COS_SECRETKEY"),
  18. Transport: &debug.DebugRequestTransport{
  19. RequestHeader: true,
  20. RequestBody: true,
  21. ResponseHeader: true,
  22. ResponseBody: true,
  23. },
  24. },
  25. })
  26. name := "test/hello.txt"
  27. v, _, err := c.Object.GetACL(context.Background(), name)
  28. if err != nil {
  29. panic(err)
  30. }
  31. for _, a := range v.AccessControlList {
  32. fmt.Printf("%s, %s, %s\n", a.Grantee.Type, a.Grantee.ID, a.Permission)
  33. }
  34. }