Skip to content

Commit

Permalink
adding contentMD5 in S3 ObjectMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
hardikSinghBehl committed Oct 8, 2024
1 parent bbd8aca commit 245dc27
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -116,6 +117,9 @@ public class ObjectMetadata {
@Nullable
private final String checksumAlgorithm;

@Nullable
private final String contentMD5;

public static Builder builder() {
return new Builder();
}
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -523,6 +531,11 @@ public String getChecksumAlgorithm() {
return checksumAlgorithm;
}

@Nullable
public String getContentMD5() {
return contentMD5;
}

public static class Builder {

private final Map<String, String> metadata = new HashMap<>();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

}
Expand Down

0 comments on commit 245dc27

Please sign in to comment.