Skip to content

Commit 360bc9b

Browse files
authored
Merge pull request #148 from agin719/cos-v4-dev
update upload/download opt
2 parents 750a7a6 + 5576819 commit 360bc9b

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

object.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,20 @@ type Object struct {
603603
// MultiUploadOptions is the option of the multiupload,
604604
// ThreadPoolSize default is one
605605
type MultiUploadOptions struct {
606-
OptIni *InitiateMultipartUploadOptions
607-
PartSize int64
608-
ThreadPoolSize int
609-
CheckPoint bool
610-
EnableVerification bool
606+
OptIni *InitiateMultipartUploadOptions
607+
PartSize int64
608+
ThreadPoolSize int
609+
CheckPoint bool
610+
DisableChecksum bool
611611
}
612612

613613
type MultiDownloadOptions struct {
614-
Opt *ObjectGetOptions
615-
PartSize int64
616-
ThreadPoolSize int
617-
CheckPoint bool
618-
CheckPointFile string
614+
Opt *ObjectGetOptions
615+
PartSize int64
616+
ThreadPoolSize int
617+
CheckPoint bool
618+
CheckPointFile string
619+
DisableChecksum bool
619620
}
620621

621622
type MultiDownloadCPInfo struct {
@@ -943,7 +944,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
943944
return nil, nil, err
944945
}
945946
// 校验
946-
if s.client.Conf.EnableCRC {
947+
if s.client.Conf.EnableCRC && !opt.DisableChecksum {
947948
fd, err := os.Open(filepath)
948949
if err != nil {
949950
return nil, nil, err
@@ -972,7 +973,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
972973
Key: name,
973974
ETag: rsp.Header.Get("ETag"),
974975
}
975-
if rsp != nil && s.client.Conf.EnableCRC {
976+
if rsp != nil && s.client.Conf.EnableCRC && !opt.DisableChecksum {
976977
scoscrc := rsp.Header.Get("x-cos-hash-crc64ecma")
977978
icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64)
978979
if icoscrc != localcrc {
@@ -1105,7 +1106,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
11051106
return v, resp, err
11061107
}
11071108

1108-
if resp != nil && s.client.Conf.EnableCRC {
1109+
if resp != nil && s.client.Conf.EnableCRC && !opt.DisableChecksum {
11091110
scoscrc := resp.Header.Get("x-cos-hash-crc64ecma")
11101111
icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64)
11111112
if icoscrc != localcrc {
@@ -1225,7 +1226,7 @@ func (s *ObjectService) Download(ctx context.Context, name string, filepath stri
12251226
if err != nil {
12261227
return rsp, err
12271228
}
1228-
if coscrc != "" && s.client.Conf.EnableCRC {
1229+
if coscrc != "" && s.client.Conf.EnableCRC && !opt.DisableChecksum {
12291230
icoscrc, _ := strconv.ParseUint(coscrc, 10, 64)
12301231
fd, err := os.Open(filepath)
12311232
if err != nil {
@@ -1344,7 +1345,7 @@ func (s *ObjectService) Download(ctx context.Context, name string, filepath stri
13441345
if opt.CheckPoint {
13451346
os.Remove(cpfile)
13461347
}
1347-
if coscrc != "" && s.client.Conf.EnableCRC {
1348+
if coscrc != "" && s.client.Conf.EnableCRC && !opt.DisableChecksum {
13481349
icoscrc, _ := strconv.ParseUint(coscrc, 10, 64)
13491350
fd, err := os.Open(filepath)
13501351
if err != nil {

object_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ func TestObjectService_Download(t *testing.T) {
796796
}
797797
defer os.Remove(filePath)
798798
// 源文件内容
799-
totalBytes := int64(1024*1024 + 1230) //1024*1024*9 + 123)
799+
totalBytes := int64(1024*1024*9 + 1230)
800800
b := make([]byte, totalBytes)
801801
_, err = rand.Read(b)
802802
newfile.Write(b)

0 commit comments

Comments
 (0)