java 使用amazon s3接口访问本地ceph rgw

ceph官网中使用java访问rgw s3的代码已经不能使用了,

http://docs.ceph.com/docs/kraken/radosgw/s3/java/

折腾了好长时间,在同事的帮助下终于实现了使用java调用rgw s3接口,代码如下:

    public static void main(String[] args) {
        String accessKey = "your accessKey";
        String secretKey = "your secretKey";

        AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);

        AmazonS3 amazonS3 = AmazonS3ClientBuilder.standard()
                .withCredentials(new AWSStaticCredentialsProvider(credentials))
                .withEndpointConfiguration(
                        new AwsClientBuilder.EndpointConfiguration(
                                "your ceph rgw site,like: http://10.0.0.12:8080",
                                ""))
                .build();
        List listBuckets = amazonS3.listBuckets();
        for (Bucket bucket : listBuckets) {
            System.out.println(bucket.getName());
        }

    }


使用过程中需要引入很多包,如有需要可以联系本人。

你可能感兴趣的:(网盘,ceph,rgw,radosgw,amazon,s3,ceph,rgw,java,amazon,s3,对象存储)