1

Due to the problem depicted here, I wish to update the content\mime type of already uploaded files. I am using JetS3t 0.9.0 to retrieve the object of interest, the I use Getting A File's Mime Type In Java to update the update the content\mime type, but I have no clue how to commit it on the object themselves, i.e. how to reflect it to the S3 storage.

Enclosed a snippet code, any help will be appreciated.

final String bucketName = "myBucketName";
final S3Bucket s3Bucket = s3Service.getBucket(bucketName);
final S3Object[] objects = s3Service.listObjects(bucketName);
String contentType = null;
for (S3Object object : objects) {
    contentType = MimetypesFileTypeMap().getContentType(object.getName());
    object.setContentType(contentType);
    //how to commit the changes?
}

Thanks.

Community
  • 1
  • 1
Mr.
  • 9,429
  • 13
  • 58
  • 82

1 Answers1

0

You have to copy the object by using copyVersionedObject to update it's metadata. By using the same source and destination key only the metadata are updated.

tkotisis
  • 3,442
  • 25
  • 30