diff --git a/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/ObjectMetadata.java b/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/ObjectMetadata.java index 95a3a51ea..fe4132732 100644 --- a/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/ObjectMetadata.java +++ b/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/ObjectMetadata.java @@ -25,6 +25,7 @@ * Container for S3 Object Metadata. For information about each field look at {@link PutObjectRequest} Javadocs. * * @author Maciej Walkowiak + * @author Hardik Singh Behl * @since 3.0 */ public class ObjectMetadata { @@ -116,6 +117,9 @@ public class ObjectMetadata { @Nullable private final String checksumAlgorithm; + @Nullable + private final String contentMD5; + public static Builder builder() { return new Builder(); } @@ -130,7 +134,7 @@ public static Builder builder() { @Nullable String ssekmsKeyId, @Nullable String ssekmsEncryptionContext, @Nullable Boolean bucketKeyEnabled, @Nullable String requestPayer, @Nullable String tagging, @Nullable String objectLockMode, @Nullable Instant objectLockRetainUntilDate, @Nullable String objectLockLegalHoldStatus, - @Nullable String expectedBucketOwner, @Nullable String checksumAlgorithm) { + @Nullable String expectedBucketOwner, @Nullable String checksumAlgorithm, @Nullable String contentMD5) { this.acl = acl; this.cacheControl = cacheControl; this.contentDisposition = contentDisposition; @@ -160,6 +164,7 @@ public static Builder builder() { this.objectLockLegalHoldStatus = objectLockLegalHoldStatus; this.expectedBucketOwner = expectedBucketOwner; this.checksumAlgorithm = checksumAlgorithm; + this.contentMD5 = contentMD5; } void apply(PutObjectRequest.Builder builder) { @@ -250,6 +255,9 @@ void apply(PutObjectRequest.Builder builder) { if (checksumAlgorithm != null) { builder.checksumAlgorithm(checksumAlgorithm); } + if (contentMD5 != null) { + builder.contentMD5(contentMD5); + } } void apply(CreateMultipartUploadRequest.Builder builder) { @@ -523,6 +531,11 @@ public String getChecksumAlgorithm() { return checksumAlgorithm; } + @Nullable + public String getContentMD5() { + return contentMD5; + } + public static class Builder { private final Map metadata = new HashMap<>(); @@ -611,6 +624,9 @@ public static class Builder { @Nullable private String checksumAlgorithm; + @Nullable + private String contentMD5; + public Builder acl(@Nullable String acl) { this.acl = acl; return this; @@ -785,13 +801,18 @@ public Builder checksumAlgorithm(@Nullable ChecksumAlgorithm checksumAlgorithm) return checksumAlgorithm(checksumAlgorithm != null ? checksumAlgorithm.toString() : null); } + public Builder contentMD5(@Nullable String contentMD5) { + this.contentMD5 = contentMD5; + return this; + } + public ObjectMetadata build() { return new ObjectMetadata(acl, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType, contentLength, expires, grantFullControl, grantRead, grantReadACP, grantWriteACP, metadata, serverSideEncryption, storageClass, websiteRedirectLocation, sseCustomerAlgorithm, sseCustomerKey, sseCustomerKeyMD5, ssekmsKeyId, ssekmsEncryptionContext, bucketKeyEnabled, requestPayer, tagging, objectLockMode, objectLockRetainUntilDate, objectLockLegalHoldStatus, - expectedBucketOwner, checksumAlgorithm); + expectedBucketOwner, checksumAlgorithm, contentMD5); } }