繁体   English   中英

适用于 android 的 AWS sdk:如何更改主机端点

[英]AWS sdk for android: How to change the host end point

我使用Wasabi进行文件存储,我需要将AWS SDK客户端主机 url 更改为 wasabi 的。 我怎样才能做到这一点?

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();

您可以像这样覆盖凭据,

    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");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM