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,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{