forked from mozillazg/go-cos
-
Notifications
You must be signed in to change notification settings - Fork 2
/
MutiUpload.go
43 lines (40 loc) · 898 Bytes
/
MutiUpload.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"context"
"net/url"
"os"
"time"
"net/http"
"fmt"
"github.com/lewzylu/go-cos"
"github.com/lewzylu/go-cos/debug"
)
func main() {
u, _ := url.Parse("http://lewzylu02-1252448703.cos.ap-guangzhou.myqcloud.com")
b := &cos.BaseURL{BucketURL: u}
c := cos.NewClient(b, &http.Client{
//设置超时时间
Timeout: 100 * time.Second,
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("COS_Key"),
SecretKey: os.Getenv("COS_Secret"),
Transport: &debug.DebugRequestTransport{
RequestHeader: false,
RequestBody: false,
ResponseHeader: false,
ResponseBody: false,
},
},
})
f,err:=os.Open("E:/cos-php-sdk.zip")
if err!=nil {panic(err)}
opt := &cos.MultiUploadOptions{
OptIni: nil,
PartSize:1,
}
v, _, err := c.Object.MultiUpload(
context.Background(), "test", f, opt,
)
if err!=nil {panic(err)}
fmt.Println(v)
}