Browse Source

update

master
jojoliang 4 years ago
parent
commit
e6618d1a4c
  1. 4
      cos.go
  2. 6
      object.go

4
cos.go

@ -71,7 +71,7 @@ func NewBucketURL(bucketName, region string, secure bool) *url.URL {
}
type Config struct {
DisableCRC bool
EnableCRC bool
}
// Client is a client manages communication with the COS API.
@ -119,7 +119,7 @@ func NewClient(uri *BaseURL, httpClient *http.Client) *Client {
UserAgent: userAgent,
BaseURL: baseURL,
Conf: &Config{
DisableCRC: false,
EnableCRC: true,
},
}
c.common.client = c

6
object.go

@ -746,7 +746,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
return nil, nil, err
}
// 校验
if !s.client.Conf.DisableCRC {
if s.client.Conf.EnableCRC {
fd, err := os.Open(filepath)
if err != nil {
return nil, nil, err
@ -771,7 +771,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
Key: name,
ETag: rsp.Header.Get("ETag"),
}
if rsp != nil && !s.client.Conf.DisableCRC {
if rsp != nil && s.client.Conf.EnableCRC {
scoscrc := rsp.Header.Get("x-cos-hash-crc64ecma")
icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64)
if icoscrc != localcrc {
@ -902,7 +902,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
return v, resp, err
}
if resp != nil && !s.client.Conf.DisableCRC {
if resp != nil && s.client.Conf.EnableCRC {
scoscrc := resp.Header.Get("x-cos-hash-crc64ecma")
icoscrc, _ := strconv.ParseUint(scoscrc, 10, 64)
if icoscrc != localcrc {

Loading…
Cancel
Save