顧客提供の秘密鍵を使用してAmazon S3にファイルをアップロードしようとしています。私はここで、このチュートリアルに従っ: http://java.awsblog.com/post/TxDQ18N7AAB31J/Generating-Amazon-S3-Pre-signed-URLs-with-SSE-C-Part-5-Finaleaws SSE-C固有の暗号化のために予約済みのURL
をマイコード:
AWSCredentials credentials = new BasicAWSCredentials("myKey", "mySecretKey");
AmazonS3 s3 = new AmazonS3Client();
try (CloseableHttpClient httpClient = HttpClientFactory.createUploadClient()) {
GeneratePresignedUrlRequest genreq = new GeneratePresignedUrlRequest("bucketName", "test7.pdf", HttpMethod.PUT);
SecretKey secretKey = generateSecretKey();
SSECustomerKey sseKey = new SSECustomerKey(secretKey);
genreq.setSSECustomerKey(sseKey);
URL puturl = s3.generatePresignedUrl(genreq);
HttpPut putreq = new HttpPut(URI.create(puturl.toExternalForm()));
putreq.addHeader(Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY, sseKey.getKey());
putreq.addHeader(Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM, SSEAlgorithm.AES256.getAlgorithm());
putreq.addHeader(Headers.SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5, sseKey.getMd5());
putreq.setEntity(new FileEntity(new File("filePath")));
HttpResponse resp = httpClient.execute(putreq);
Assert.assertTrue(resp.getStatusLine().getStatusCode() == 200);
} catch (IOException e) {
Assert.fail();
}
URLが生成されます、と私は消費しようとすると、私は必要なヘッダを提供していますが、問題は、応答は403であるということです禁止されています。
私には何が欠けていますか?
を '403 Forbidden'は通常、エラーの説明とレスポンスボディを伴っている、XMLで...あなたはそれをキャプチャすることができますし、質問にそれを編集しますか? –
これは問題であり、これ以上の説明はなく、ただ禁止されています。 'HttpResponseProxy {HTTP/1.1 403 Forbidden [x-amz-request-id:theId、x-amz-id-2:the2ndId、content-type:アプリケーション/ xml、転送エンコーディング:チャンク、Date:Tue 、26 Apr 2016 13:22:27 GMT、接続:閉じる、サーバー:AmazonS3] ResponseEntityProxy {[コンテンツタイプ:アプリケーション/ xml、チャンク:true]}} ' – madalina
あなたが使用しているものは、レスポンスボディを隠すことです。それらはただのヘッダーです。 –