How to change metadata on an object in Amazon S3

前端 未结 7 1114
迷失自我
迷失自我 2020-12-24 06:01

If you have already uploaded an object to an Amazon S3 bucket, how do you change the metadata using the API? It is possible to do this in the AWS Management Console, but it

相关标签:
7条回答
  • 2020-12-24 06:38

    here is the code that worked for me. I'm using aws-java-sdk-s3 version 1.10.15

    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentType(fileExtension.getMediaType());
    
    s3Client.putObject(new PutObjectRequest(bucketName, keyName, tempFile)
                        .withMetadata(metadata));
    
    0 讨论(0)
提交回复
热议问题