最近更新时间:2021-09-18
以下代码用于设置文件元信息:
public void testObjectMeta() { try { // Upload a text string as a new object. s3.putObject(bucketName, objectName, "Uploaded String Object"); // Upload a file as a new object with ContentType and title specified. PutObjectRequest request = new PutObjectRequest(bucketName, objectName, new File(filePath)); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentType("plain/text"); metadata.addUserMetadata("x-amz-meta-title", "someTitle"); request.setMetadata(metadata); s3.putObject(request); } catch(AmazonServiceException e) { System.err.println(e.getErrorMessage()); } } |