使用AWS Java SDK在Google Storage S3兼容存储桶中列出对象

时间:2018-07-08 12:08:47

标签: amazon-s3 google-cloud-storage aws-sdk

我们正在尝试使用AWS S3 Java SDK测试从使用AWS S3存储到Google存储服务的可能迁移

我们已根据documentation

配置了Google存储空间

使用S3 browser之类的软件配置存储似乎可行。 但是,使用下面的代码片段,有一个IllegalArgumentException:

    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.setSignerOverride("S3SignerType");
    AmazonS3 myS3Client = AmazonS3ClientBuilder.standard().
            withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("MY_ACCESS_KEY", "MY_SECRET_KEY"))).
            withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("storage.googleapis.com", "default")).
            withClientConfiguration(clientConfig).
            build();

此呼叫返回正确的响应

  List<Bucket> buckets = myS3Client.listBuckets();

但是,此调用返回异常:

  myS3Client.listObjects("my-test-bucket");

引发异常:

com.amazonaws.services.s3.model.AmazonS3Exception: Invalid argument. (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: null; S3 Extended Request ID: null), S3 Extended Request ID: null
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1640)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1304)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1058)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:743)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4325)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4272)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4266)
    at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:834)
    at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:803)

在这里感谢任何帮助

0 个答案:

没有答案