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.

43 lines
887 B

5 years ago
  1. package main
  2. import (
  3. "context"
  4. "net/http"
  5. "net/url"
  6. "os"
  7. "fmt"
  8. "github.com/tencentyun/cos-go-sdk-v5"
  9. "github.com/tencentyun/cos-go-sdk-v5/debug"
  10. )
  11. func main() {
  12. uin := "100010805041"
  13. appid := 1259654469
  14. u, _ := url.Parse("https://" + uin + ".cos-control.ap-chengdu.myqcloud.com")
  15. b := &cos.BaseURL{BatchURL: u}
  16. c := cos.NewClient(b, &http.Client{
  17. Transport: &cos.AuthorizationTransport{
  18. SecretID: os.Getenv("COS_SECRETID"),
  19. SecretKey: os.Getenv("COS_SECRETKEY"),
  20. Transport: &debug.DebugRequestTransport{
  21. RequestHeader: true,
  22. RequestBody: true,
  23. ResponseHeader: true,
  24. ResponseBody: true,
  25. },
  26. },
  27. })
  28. headers := &cos.BatchRequestHeaders{
  29. XCosAppid: appid,
  30. }
  31. res, _, err := c.Batch.ListJobs(context.Background(), nil, headers)
  32. if err != nil {
  33. panic(err)
  34. }
  35. if res != nil && res.Jobs != nil {
  36. fmt.Printf("%+v", res.Jobs)
  37. }
  38. }