我的当前用于在S3存储桶上复制对象的基于REST的访问的代码不起作用。我的S3存储桶配置为https访问,并启用了sse。我如何修改下面的代码使其工作? 目前,我只是收到一条错误消息'Caught a AmazonClientException,这意味着客户端在尝试与S3通信时遇到错误,例如无法访问网络。 错误消息:无法执行的HTTP请求:mybucket.s3.amazonaws.com”带有https连接的亚马逊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
您的存储桶在存储桶名称中没有点,是吗? –