本文整理汇总了Java中com.amazonaws.services.s3.model.PutObjectRequest.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java PutObjectRequest.getMetadata方法的具体用法?Java PutObjectRequest.getMetadata怎么用?Java PutObjectRequest.getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.model.PutObjectRequest
的用法示例。
在下文中一共展示了PutObjectRequest.getMetadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
@Test
@Override
public void test() throws Exception {
AmazonS3 amazonS3Client = TestUtils.getPropertyValue(this.s3MessageHandler, "transferManager.s3",
AmazonS3.class);
InputStream payload = new StringInputStream("a");
Message<?> message = MessageBuilder.withPayload(payload)
.setHeader("key", "myInputStream")
.build();
this.channels.input().send(message);
ArgumentCaptor<PutObjectRequest> putObjectRequestArgumentCaptor =
ArgumentCaptor.forClass(PutObjectRequest.class);
verify(amazonS3Client, atLeastOnce()).putObject(putObjectRequestArgumentCaptor.capture());
PutObjectRequest putObjectRequest = putObjectRequestArgumentCaptor.getValue();
assertThat(putObjectRequest.getBucketName(), equalTo(S3_BUCKET));
assertThat(putObjectRequest.getKey(), equalTo("myInputStream"));
assertNull(putObjectRequest.getFile());
assertNotNull(putObjectRequest.getInputStream());
ObjectMetadata metadata = putObjectRequest.getMetadata();
assertThat(metadata.getContentMD5(), equalTo(Md5Utils.md5AsBase64(payload)));
assertThat(metadata.getContentLength(), equalTo(1L));
assertThat(metadata.getContentType(), equalTo(MediaType.APPLICATION_JSON_VALUE));
assertThat(metadata.getContentDisposition(), equalTo("test.json"));
}