title: Updating AWS S3 expiration time
body: <p><strong>I would like to know how to EXTEND a key's expiration.</strong>  I am not referring to the signed URL that accesses the object but the key itself.</p>
  
  <p>I setup AWS to have a rule that all objects within the bucket should expire in 90 days.  This is what I want to happen in most cases.  Now and then I need to extend an individual key's lifetime by up to an additional 90 days.  In fact resetting the countdown is fine.</p>
  
  <p>I have tried this using the AWS SDK to no avail.</p>
  
  <p>My First attempt was to alter metadata using copyObject:</p>
  
  <pre><code>ObjectMetadata meta = s3client.getObjectMetadata( bucket, key );
  meta.setExpirationTime( getFutureDate( 90*DAYS ) );
  CopyObjectRequest copyObjectRequest = new CopyObjectRequest( bucket, key, bucket, key );
  copyObjectRequest.setNewObjectMetadata( meta );
  copyObjectRequest.setStorageClass( StorageClass.Standard );
  s3client.copyObject( copyObjectRequest );
  </code></pre>
  
  <p>The above did not work.  The JavaDoc even clued me in as to why (read it after attempting).</p>
  
  <pre><code>void com.amazonaws.services.s3.model.ObjectMetadata.setExpirationTime(Date expirationTime)
  
  For internal use only. This will *not* set the object's expiration time, and is only used to set the value in the object after receiving the value in a response from S3.
  </code></pre>
  
  <p>I then tried a variation on the above based on this link (added setStorageClass):
  <a href="https://alestic.com/2013/09/s3-lifecycle-extend/" rel="noreferrer">https://alestic.com/2013/09/s3-lifecycle-extend/</a></p>
  
  <p>Any help is appreciated.</p>