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.

44 lines
889 B

  1. package main
  2. import (
  3. "context"
  4. "net/http"
  5. "net/url"
  6. "os"
  7. "time"
  8. "fmt"
  9. "github.com/tencentyun/cos-go-sdk-v5"
  10. "github.com/tencentyun/cos-go-sdk-v5/debug"
  11. )
  12. func main() {
  13. u, _ := url.Parse("http://alanbj-1251668577.cos.ap-beijing.myqcloud.com")
  14. b := &cos.BaseURL{BucketURL: u}
  15. c := cos.NewClient(b, &http.Client{
  16. //设置超时时间
  17. Timeout: 100 * time.Second,
  18. Transport: &cos.AuthorizationTransport{
  19. SecretID: os.Getenv("COS_SECRETID"),
  20. SecretKey: os.Getenv("COS_SECRETKEY"),
  21. Transport: &debug.DebugRequestTransport{
  22. RequestHeader: false,
  23. RequestBody: false,
  24. ResponseHeader: false,
  25. ResponseBody: false,
  26. },
  27. },
  28. })
  29. opt := &cos.MultiUploadOptions{
  30. OptIni: nil,
  31. PartSize: 1,
  32. }
  33. v, _, err := c.Object.MultiUpload(
  34. context.Background(), "test/gomulput1G", "./test1G", opt,
  35. )
  36. if err != nil {
  37. panic(err)
  38. }
  39. fmt.Println(v)
  40. }