Skip to content

Commit 0f3c6f4

Browse files
author
jojoliang
committed
update download
1 parent 3cb24d0 commit 0f3c6f4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

object.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,14 +1241,20 @@ func (s *ObjectService) Download(ctx context.Context, name string, filepath stri
12411241
if opt.Opt != nil && opt.Opt.Range != "" {
12421242
return nil, fmt.Errorf("Download doesn't support Range Options")
12431243
}
1244-
// 获取文件长度和CRC
1245-
var coscrc string
1246-
resp, err := s.Head(ctx, name, nil, id...)
1244+
headOpt := &ObjectHeadOptions{}
1245+
if opt.Opt != nil {
1246+
headOpt.XCosSSECustomerAglo = opt.Opt.XCosSSECustomerAglo
1247+
headOpt.XCosSSECustomerKey = opt.Opt.XCosSSECustomerKey
1248+
headOpt.XCosSSECustomerKeyMD5 = opt.Opt.XCosSSECustomerKeyMD5
1249+
headOpt.XOptionHeader = opt.Opt.XOptionHeader
1250+
}
1251+
resp, err := s.Head(ctx, name, headOpt, id...)
12471252
if err != nil {
12481253
return resp, err
12491254
}
1255+
// 获取文件长度和CRC
12501256
// 如果对象不存在x-cos-hash-crc64ecma,则跳过不做校验
1251-
coscrc = resp.Header.Get("x-cos-hash-crc64ecma")
1257+
coscrc := resp.Header.Get("x-cos-hash-crc64ecma")
12521258
strTotalBytes := resp.Header.Get("Content-Length")
12531259
totalBytes, err := strconv.ParseInt(strTotalBytes, 10, 64)
12541260
if err != nil {

0 commit comments

Comments
 (0)