94474: Transfer manger should be class wide

This commit is contained in:
Jens Vannerum
2022-09-20 15:19:19 +02:00
parent 5ae5398b99
commit 74b56d6fe1

View File

@@ -75,6 +75,12 @@ public class S3BitStoreService implements BitStoreService {
*/
private AmazonS3 s3Service = null;
/**
* S3 transfer manager
* this is reused between put calls to use less resources for multiple uploads
*/
private TransferManager tm = null;
private static final ConfigurationService configurationService
= DSpaceServicesFactory.getInstance().getConfigurationService();
public S3BitStoreService() {
@@ -128,6 +134,11 @@ public class S3BitStoreService implements BitStoreService {
}
log.info("AWS S3 Assetstore ready to go! bucket:" + bucketName);
tm = TransferManagerBuilder.standard()
.withAlwaysCalculateMultipartMd5(true)
.withS3Client(s3Service)
.build();
}
@@ -184,12 +195,6 @@ public class S3BitStoreService implements BitStoreService {
// Therefore, we precalculate before uploading
String localChecksum = org.dspace.curate.Utils.checksum(scratchFile, CSA);
TransferManager tm = TransferManagerBuilder.standard()
.withAlwaysCalculateMultipartMd5(true)
.withS3Client(s3Service)
.build();
Upload upload = tm.upload(bucketName, key, scratchFile);
upload.waitForUploadResult();