@@ -120,6 +120,9 @@ public class ObjectMetadata {
120120 @ Nullable
121121 private final String contentMD5 ;
122122
123+ @ Nullable
124+ private final MetadataDirective metadataDirective ;
125+
123126 public static Builder builder () {
124127 return new Builder ();
125128 }
@@ -128,8 +131,8 @@ public static Builder builder() {
128131 @ Nullable String contentEncoding , @ Nullable String contentLanguage , @ Nullable String contentType ,
129132 @ Nullable Long contentLength , @ Nullable Instant expires , @ Nullable String grantFullControl ,
130133 @ Nullable String grantRead , @ Nullable String grantReadACP , @ Nullable String grantWriteACP ,
131- @ Nullable Map <String , String > metadata , @ Nullable String serverSideEncryption ,
132- @ Nullable String storageClass , @ Nullable String websiteRedirectLocation ,
134+ @ Nullable Map <String , String > metadata , @ Nullable MetadataDirective metadataDirective ,
135+ @ Nullable String serverSideEncryption , @ Nullable String storageClass , @ Nullable String websiteRedirectLocation ,
133136 @ Nullable String sseCustomerAlgorithm , @ Nullable String sseCustomerKey , @ Nullable String sseCustomerKeyMD5 ,
134137 @ Nullable String ssekmsKeyId , @ Nullable String ssekmsEncryptionContext , @ Nullable Boolean bucketKeyEnabled ,
135138 @ Nullable String requestPayer , @ Nullable String tagging , @ Nullable String objectLockMode ,
@@ -148,6 +151,7 @@ public static Builder builder() {
148151 this .grantReadACP = grantReadACP ;
149152 this .grantWriteACP = grantWriteACP ;
150153 this .metadata = metadata ;
154+ this .metadataDirective = metadataDirective ;
151155 this .serverSideEncryption = serverSideEncryption ;
152156 this .storageClass = storageClass ;
153157 this .websiteRedirectLocation = websiteRedirectLocation ;
@@ -261,7 +265,7 @@ void apply(PutObjectRequest.Builder builder) {
261265 }
262266
263267 void apply (CopyObjectRequest .Builder builder ) {
264- builder .metadataDirective (MetadataDirective .REPLACE );
268+ builder .metadataDirective (metadataDirective == null ? MetadataDirective .REPLACE : metadataDirective );
265269 if (acl != null ) {
266270 builder .acl (acl );
267271 }
@@ -716,6 +720,9 @@ public static class Builder {
716720 @ Nullable
717721 private String contentMD5 ;
718722
723+ @ Nullable
724+ private MetadataDirective metadataDirective ;
725+
719726 public Builder acl (@ Nullable String acl ) {
720727 this .acl = acl ;
721728 return this ;
@@ -785,6 +792,11 @@ public Builder metadata(@Nullable String key, String value) {
785792 return this ;
786793 }
787794
795+ public Builder metadataDirective (@ Nullable MetadataDirective metadataDirective ) {
796+ this .metadataDirective = metadataDirective ;
797+ return this ;
798+ }
799+
788800 public Builder serverSideEncryption (@ Nullable String serverSideEncryption ) {
789801 this .serverSideEncryption = serverSideEncryption ;
790802 return this ;
@@ -898,7 +910,7 @@ public Builder contentMD5(@Nullable String contentMD5) {
898910 public ObjectMetadata build () {
899911 return new ObjectMetadata (acl , cacheControl , contentDisposition , contentEncoding , contentLanguage ,
900912 contentType , contentLength , expires , grantFullControl , grantRead , grantReadACP , grantWriteACP ,
901- metadata , serverSideEncryption , storageClass , websiteRedirectLocation , sseCustomerAlgorithm ,
913+ metadata , metadataDirective , serverSideEncryption , storageClass , websiteRedirectLocation , sseCustomerAlgorithm ,
902914 sseCustomerKey , sseCustomerKeyMD5 , ssekmsKeyId , ssekmsEncryptionContext , bucketKeyEnabled ,
903915 requestPayer , tagging , objectLockMode , objectLockRetainUntilDate , objectLockLegalHoldStatus ,
904916 expectedBucketOwner , checksumAlgorithm , contentMD5 );
0 commit comments