S3バケットのオブジェクトをコピーするためのRESTベースのアクセス用の私の現在のコードは機能しません。私のS3バケットはhttpsアクセス用に設定されており、sseが有効になっています。それを動作させるには、以下のコードをどのように変更すればよいですか? 現在のところ、「AmazonClientExceptionが発生しました」というエラーメッセージが表示されます。これは、ネットワークにアクセスできないなど、S3と通信しようとしているときにクライアントでエラーが発生したことを意味します。 mybucket.s3.amazonaws.com」それを解決https接続のあるAmazon S3 SDK
@PUT
@Path("/copy/{bucketName}")
public void copyObject(@PathParam("bucketName") String bucketName, @QueryParam("fromPath") String fromPath,
@QueryParam("toPath") String toPath) throws AmazonClientException {
AmazonS3 s3client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain());
try {
CopyObjectRequest copyObjRequest = new CopyObjectRequest(bucketName, fromPath, bucketName, toPath);
System.out.println("Copying object.");
s3client.copyObject(copyObjRequest);
} catch (AmazonServiceException ase) {
System.out.println("Caught an AmazonServiceException, " + "which means your request made it "
+ "to Amazon S3, but was rejected with an error " + "response for some reason.");
System.out.println("Error Message: " + ase.getMessage());
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
System.out.println("Error Type: " + ase.getErrorType());
System.out.println("Request ID: " + ase.getRequestId());
} catch (AmazonClientException ace) {
System.out.println("Caught an AmazonClientException, " + "which means the client encountered "
+ "an internal error while trying to " + " communicate with S3, "
+ "such as not being able to access the network.");
System.out.println("Error Message: " + ace.getMessage());
}
}
使用しているSDKとそのバージョンは何ですか? – error2007s
あなたのバケットにはバケット名にドットはありませんか? –