我正尝试将File
上传到AWS,在那里我已经将SDK生成的大部分信息存储在Map<String, String>
中(它们由API提供):
"Content-Type": "application/pdf",
"bucket": "bucket-name",
"acl": "private",
"key": "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"policy": "xxxxxxxx==",
"x-amz-algorithm": "AWS4-HMAC-SHA256",
"x-amz-credential": "ASIAxxxxxxxxx/20180202/eu-west-2/s3/aws4_request",
"x-amz-signature": "xxxx"
"x-amz-date": "yyyyMMddThhmmssZ",
"x-amz-meta-a": "some meta data",
"x-amz-meta-b": "some meta data"
到目前为止,我有:
AmazonS3 s3 = AmazonS3ClientBuilder.standard().build();
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType(map.get("Content-Type"));
metadata.setSSEAlgorithm(map.get("x-amz-algorithm"));
Map<String, String> userMetadata = new HashMap<String, String>();
userMetadata.put("a", map.get("x-amz-meta-a"));
metadata.setUserMetadata(userMetadata);
s3.putObject(new PutObjectRequest(
map.get("bucket"),
map.get("ket"),
new FileInputStream(file),
metadata
))
现在如何设置credential
和signature
字段?
如果不更合理地使用SDK,那么将不胜感激一些示例,我还没有设法通过简单的HTTP post
使它正常工作。