refactor: use S3MultipartUpload if greater than S3_MULTIPART_MIN_PART_SIZE
This commit is contained in:
parent
7411228106
commit
9f5b676f47
|
@ -1678,6 +1678,7 @@ func (s *S5API) pinImportCronJob(cid string, url string, proofUrl string, userId
|
|||
|
||||
}(verifier)
|
||||
|
||||
if parsedCid.Size < storage.S3_MULTIPART_MIN_PART_SIZE {
|
||||
_, err = client.PutObject(ctx, &s3.PutObjectInput{
|
||||
Bucket: aws.String(s.config.Config().Core.Storage.S3.BufferBucket),
|
||||
Key: aws.String(cid),
|
||||
|
@ -1685,8 +1686,16 @@ func (s *S5API) pinImportCronJob(cid string, url string, proofUrl string, userId
|
|||
ContentLength: aws.Int64(int64(parsedCid.Size)),
|
||||
})
|
||||
if err != nil {
|
||||
s.logger.Error("error uploading object", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err := s.storage.S3MultipartUpload(ctx, verifier, s.config.Config().Core.Storage.S3.BufferBucket, cid, parsedCid.Size)
|
||||
if err != nil {
|
||||
s.logger.Error("error uploading object", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
upload, err := s.storage.UploadObject(ctx, s5.GetStorageProtocol(s.protocol), nil, &renter.MultiPartUploadParams{
|
||||
ReaderFactory: func(start uint, end uint) (io.ReadCloser, error) {
|
||||
|
|
Loading…
Reference in New Issue