refactor: use S3MultipartUpload if greater than S3_MULTIPART_MIN_PART_SIZE

This commit is contained in:
Derrick Hammer 2024-02-27 06:14:27 -05:00
parent 7411228106
commit 9f5b676f47
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 17 additions and 8 deletions

View File

@ -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) {