@@ -138,29 +138,30 @@ public List<Bucket> listBuckets() {
138138
139139 public S3Object putObject (String bucketName , String key , byte [] data ,
140140 String contentType , Map <String , String > metadata ) {
141- return putObject (bucketName , key , data , contentType , metadata , null , null , null , null );
141+ return putObject (bucketName , key , data , contentType , metadata , null , null , null , null , null , null );
142142 }
143143
144144 public S3Object putObject (String bucketName , String key , byte [] data ,
145145 String contentType , Map <String , String > metadata ,
146146 String objectLockMode , Instant retainUntilDate , String legalHoldStatus ) {
147- return putObject (bucketName , key , data , contentType , metadata , null ,
148- objectLockMode , retainUntilDate , legalHoldStatus );
147+ return putObject (bucketName , key , data , contentType , metadata , null , null ,
148+ objectLockMode , retainUntilDate , legalHoldStatus , null );
149149 }
150150
151151 public S3Object putObject (String bucketName , String key , byte [] data ,
152152 String contentType , Map <String , String > metadata , String storageClass ,
153153 String objectLockMode , Instant retainUntilDate , String legalHoldStatus ) {
154154 return putObject (bucketName , key , data , contentType , metadata , storageClass , null ,
155- objectLockMode , retainUntilDate , legalHoldStatus );
155+ objectLockMode , retainUntilDate , legalHoldStatus , null );
156156 }
157157
158158 public S3Object putObject (String bucketName , String key , byte [] data ,
159159 String contentType , Map <String , String > metadata , String storageClass ,
160160 String contentEncoding ,
161- String objectLockMode , Instant retainUntilDate , String legalHoldStatus ) {
161+ String objectLockMode , Instant retainUntilDate , String legalHoldStatus ,
162+ String cacheControl ) {
162163 S3Object object = storeObject (bucketName , key , data , contentType , metadata , storageClass , null , null ,
163- objectLockMode , retainUntilDate , legalHoldStatus , contentEncoding );
164+ objectLockMode , retainUntilDate , legalHoldStatus , contentEncoding , cacheControl );
164165 fireNotifications (bucketName , key , "ObjectCreated:Put" , object );
165166 return object ;
166167 }
@@ -171,22 +172,22 @@ public S3Object putObject(String bucketName, String key, byte[] data,
171172 private S3Object storeObject (String bucketName , String key , byte [] data ,
172173 String contentType , Map <String , String > metadata ) {
173174 return storeObject (bucketName , key , data , contentType , metadata , null , null , null ,
174- null , null , null , null );
175+ null , null , null , null , null );
175176 }
176177
177178 private S3Object storeObject (String bucketName , String key , byte [] data ,
178179 String contentType , Map <String , String > metadata , String storageClass ,
179180 S3Checksum checksum , List <Part > parts ,
180181 String objectLockMode , Instant retainUntilDate , String legalHoldStatus ) {
181182 return storeObject (bucketName , key , data , contentType , metadata , storageClass , checksum , parts ,
182- objectLockMode , retainUntilDate , legalHoldStatus , null );
183+ objectLockMode , retainUntilDate , legalHoldStatus , null , null );
183184 }
184185
185186 private S3Object storeObject (String bucketName , String key , byte [] data ,
186187 String contentType , Map <String , String > metadata , String storageClass ,
187188 S3Checksum checksum , List <Part > parts ,
188189 String objectLockMode , Instant retainUntilDate , String legalHoldStatus ,
189- String contentEncoding ) {
190+ String contentEncoding , String cacheControl ) {
190191 Bucket bucket = bucketStore .get (bucketName )
191192 .orElseThrow (() -> new AwsException ("NoSuchBucket" ,
192193 "The specified bucket does not exist." , 404 ));
@@ -199,6 +200,7 @@ private S3Object storeObject(String bucketName, String key, byte[] data,
199200 object .setChecksum (checksum != null ? copyChecksum (checksum ) : buildChecksum (data , parts , false ));
200201 object .setParts (copyParts (parts ));
201202 object .setContentEncoding (contentEncoding );
203+ object .setCacheControl (cacheControl );
202204
203205 if (bucket .isVersioningEnabled ()) {
204206 String versionId = UUID .randomUUID ().toString ();
@@ -551,13 +553,14 @@ public S3Object copyObject(String sourceBucket, String sourceKey,
551553 String metadataDirective , Map <String , String > replacementMetadata ,
552554 String storageClass , String contentType ) {
553555 return copyObject (sourceBucket , sourceKey , destBucket , destKey , metadataDirective ,
554- replacementMetadata , storageClass , contentType , null );
556+ replacementMetadata , storageClass , contentType , null , null );
555557 }
556558
557559 public S3Object copyObject (String sourceBucket , String sourceKey ,
558560 String destBucket , String destKey ,
559561 String metadataDirective , Map <String , String > replacementMetadata ,
560- String storageClass , String contentType , String contentEncoding ) {
562+ String storageClass , String contentType , String contentEncoding ,
563+ String cacheControl ) {
561564 S3Object source = getObject (sourceBucket , sourceKey );
562565 ensureBucketExists (destBucket );
563566
@@ -570,9 +573,10 @@ public S3Object copyObject(String sourceBucket, String sourceKey,
570573 String effectiveContentType = replaceMetadata && contentType != null ? contentType : source .getContentType ();
571574 String effectiveStorageClass = storageClass != null ? storageClass : source .getStorageClass ();
572575 String effectiveContentEncoding = replaceMetadata && contentEncoding != null ? contentEncoding : source .getContentEncoding ();
576+ String effectiveCacheControl = replaceMetadata && cacheControl != null ? cacheControl : source .getCacheControl ();
573577 S3Object copy = storeObject (destBucket , destKey , source .getData (), effectiveContentType , metadata ,
574578 effectiveStorageClass , source .getChecksum (), source .getParts (), null , null , null ,
575- effectiveContentEncoding );
579+ effectiveContentEncoding , effectiveCacheControl );
576580 copy .setETag (source .getETag ());
577581 LOG .debugv ("Copied object: {0}/{1} -> {2}/{3}" , sourceBucket , sourceKey , destBucket , destKey );
578582 fireNotifications (destBucket , destKey , "ObjectCreated:Copy" , copy );
@@ -1415,6 +1419,7 @@ private static S3Object copyObject(S3Object source) {
14151419 copy .setMetadata (new HashMap <>(source .getMetadata ()));
14161420 copy .setContentType (source .getContentType ());
14171421 copy .setContentEncoding (source .getContentEncoding ());
1422+ copy .setCacheControl (source .getCacheControl ());
14181423 copy .setSize (source .getSize ());
14191424 copy .setLastModified (source .getLastModified ());
14201425 copy .setETag (source .getETag ());
0 commit comments