Amazon S3 AWS因未知原因开始提供错误代码400

时间:2015-02-24 19:08:33

标签: java amazon-web-services amazon-s3

我不知道从什么时候开始,但在我的开发机器上,我使用带有Java的AWS开发工具包得到以下错误:

2015-02-24 18:57:05,834 DEBUG ~ Receiving response: HTTP/1.1 400 Bad Request
2015-02-24 18:57:05,834 DEBUG ~ << HTTP/1.1 400 Bad Request
2015-02-24 18:57:05,834 DEBUG ~ << Server: nginx
2015-02-24 18:57:05,834 DEBUG ~ << Date: Tue, 24 Feb 2015 18:57:05 GMT
2015-02-24 18:57:05,834 DEBUG ~ << Content-Type: application/xml
2015-02-24 18:57:05,834 DEBUG ~ << Transfer-Encoding: chunked
2015-02-24 18:57:05,834 DEBUG ~ << Connection: keep-alive
2015-02-24 18:57:05,834 DEBUG ~ << Bucket: "testmedia"
2015-02-24 18:57:05,834 DEBUG ~ << Accept-Ranges: bytes
2015-02-24 18:57:05,834 DEBUG ~ << Age: 0
2015-02-24 18:57:05,834 DEBUG ~ << X-Cache-Hit: No
2015-02-24 18:57:05,835 DEBUG ~ Connection can be kept alive indefinitely
2015-02-24 18:57:05,835 DEBUG ~  << "51[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~  << "<?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code></Error>"
2015-02-24 18:57:05,835 DEBUG ~  << "[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~  << "0[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~  << "[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ Connection [id: 8][route: {s}->https://testmedia.xxx] can be kept alive indefinitely
2015-02-24 18:57:05,835 DEBUG ~ Connection released: [id: 8][route: {s}->https://testmedia.xxx][total kept alive: 1; route allocated: 1 of 50; total allocated: 1 of 50]
2015-02-24 18:57:05,836 DEBUG ~ Received error response: com.amazonaws.services.s3.model.AmazonS3Exception: null (Service: null; Status Code: 400; Error Code: InvalidArgument; Request ID: null), S3 Extended Request ID: null

我可以上传文件,因此凭据似乎没问题,但我似乎无法下载它。我正在使用Play!框架(1.2.7)运行JDK 1.7和AWS SDK 1.9.22。

这可能是什么原因?

最近我确实从JDK 1.6切换到1.7,因为AWS上的1.​​6签名问题。我还没有在我的生产服务器上拥有它,所以它可能与OS X有关,但是我不敢将我的代码部署到生产中,直到我确定它不会破坏为止。

(aws-sdk-java / 1.9.22 Mac_OS_X / 10.10.3 Java_HotSpot(TM)_64-Bit_Server_VM / 24.71-b01 / 1.7.0_71)

[编辑:] 我的Java代码:

AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setConnectionTimeout(2500);

AmazonS3 conn = new AmazonS3Client(credentials, clientConfig);
conn.setEndpoint(hostUrl);    
S3Object object = conn.getObject(new GetObjectRequest(bucket, fileKey));

2 个答案:

答案 0 :(得分:1)

它与CloudStack和SDK版本有关。我降级到1.8.11,这一切都运行良好!

答案 1 :(得分:1)

降级到1.8.x或使用s3signer,如:

RewriteRule

见这里: https://github.com/elastic/elasticsearch-cloud-aws/issues/155