1

由于此处描述的问题,我希望更新已上传文件的 content\mime 类型。我正在使用JetS3t 0.9.0 来检索感兴趣的对象,我使用Getting A File's Mime Type In Java来更新更新 content\mime 类型,但我不知道如何在对象本身上提交它,即如何将其反映到 S3 存储。

附上一段代码,任何帮助将不胜感激。

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?
}

谢谢。

4

1 回答 1

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.

于 2012-11-12T13:36:22.627 回答