I've written this simplest code to connect to S3 -
String accessKey = "somekey";
String secretKey = "somesecret";
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3 conn = new AmazonS3Client(credentials);
conn.setEndpoint("advenio-ireland.s3.amazonaws.com");
List<Bucket> buckets = conn.listBuckets();
for (Bucket bucket : buckets) {
System.out.println(bucket.getName() + "\t" +
StringUtils.fromDate(bucket.getCreationDate()));
}
I'me getting below error -
Caught an AmazonServiceException, which means your request made it to Amazon S3, but was rejected with an error response for some reason. Error Message: The request signature we calculated does not match the signature you provided. Check your key and signing method. (Service: Amazon S3; Status Code: 403; Error Code: SignatureDoesNotMatch; Request ID: 396D5E93F8D827DE) HTTP Status Code: 403 AWS Error Code: SignatureDoesNotMatch Error Type: Client Request ID: 396D5E93F8D827DE
I'm able to connect through S3 browser with the same access key and secret key but through code its not working! I'm using AWS-SDK version 1.8.7 Please suggest,
Aucun commentaire:
Enregistrer un commentaire