refactor: use S3MultipartUpload if greater than S3_MULTIPART_MIN_PART_SIZE
This commit is contained in:
parent
7411228106
commit
9f5b676f47
25
api/s5/s5.go
25
api/s5/s5.go
|
@ -1678,14 +1678,23 @@ func (s *S5API) pinImportCronJob(cid string, url string, proofUrl string, userId
|
||||||
|
|
||||||
}(verifier)
|
}(verifier)
|
||||||
|
|
||||||
_, err = client.PutObject(ctx, &s3.PutObjectInput{
|
if parsedCid.Size < storage.S3_MULTIPART_MIN_PART_SIZE {
|
||||||
Bucket: aws.String(s.config.Config().Core.Storage.S3.BufferBucket),
|
_, err = client.PutObject(ctx, &s3.PutObjectInput{
|
||||||
Key: aws.String(cid),
|
Bucket: aws.String(s.config.Config().Core.Storage.S3.BufferBucket),
|
||||||
Body: verifier,
|
Key: aws.String(cid),
|
||||||
ContentLength: aws.Int64(int64(parsedCid.Size)),
|
Body: verifier,
|
||||||
})
|
ContentLength: aws.Int64(int64(parsedCid.Size)),
|
||||||
if err != nil {
|
})
|
||||||
return err
|
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{
|
upload, err := s.storage.UploadObject(ctx, s5.GetStorageProtocol(s.protocol), nil, &renter.MultiPartUploadParams{
|
||||||
|
|
Loading…
Reference in New Issue