1

I'm using Wasabi for my file storage and I need to change the AWS SDK clients host url to that of wasabi. How can I do that?

AmazonS3Client s3client = new AmazonS3Client(new AWSCredentials() {
        @Override
        public String getAWSAccessKeyId() {
            return accessKey;
        }
        @Override
        public String getAWSSecretKey() {
           return secretKey;
        }
});

/// Tried this but its not changing the endpoint and its still showing as aws s3 default endpoint.
s3client.setEndpoint(String.format("https://s3.wasabisys.com", Regions.US_EAST_1));
s3client.setRegion(Region.getRegion(Regions.US_EAST_1));



File fileToUpload = new File(filePath);
PutObjectRequest putRequest = new PutObjectRequest("ALPHA", "upload/" + 
fileToUpload.getName(), fileToUpload);

PutObjectResult putResponse = s3client.putObject(putRequest);
putResponse.getContentMd5();
krishnakumarcn
  • 3,959
  • 6
  • 39
  • 69

1 Answers1

1

You can override the credentials like this,

    AWSCredentials myCredentials = new BasicAWSCredentials(
            "AWS_ACCESS_KEY_ID", "AWS_SECRET_KEY_ID");
    AmazonS3 s3client = new AmazonS3Client(myCredentials, 
    Region.getRegion(Regions.AP_EAST_1));
    s3client.setEndpoint("ENDPOINT_S3");
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77