Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to authenticate amazon s3 endpoint in java

Tags:

java

amazon-s3

I've amazon aws s3 endpoint, access key and secret key, i want to validate my endpoint using these key in java, can someone help how to test my endpoint if you can share some sample code will be very helpful.

Thanks

I tried the below code but its not authenticating:

public class AmazonS3Example
{
  private static final String SUFFIX = "/";

  public static void main(String[] args)
  {
    AWSCredentials credentials = new BasicAWSCredentials(
            "YourAccessKeyID",
            "YourSecretAccessKey");
    AmazonS3 s3client = new AmazonS3Client(credentials);
    s3client.setEndpoint("http://someendpoing.com");
  }
}
like image 910
learn java Avatar asked Mar 08 '26 03:03

learn java


1 Answers

An endpoint is an Amazon supplied value.

http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html

E.g. s3.amazonaws.com for US Standard.

Or s3-<region>.amazonaws.com, E.g. s3-eu-west-1.amazonaws.com

You are using an incorrect endpoint. Plus in most situations you want to set the Amazon Region, not the endpoint specifically. See http://docs.aws.amazon.com/AmazonS3/latest/dev/create-bucket-get-location-example.html for an example.

With your Account credentials, Region and Bucket name, Amazon S3 API has all it needs to find your files.

like image 125
kervin Avatar answered Mar 10 '26 19:03

kervin