gpt4 book ai didi

java - Amazon S3 AWS 开始给出错误代码 400,原因不明

转载 作者:行者123 更新时间:2023-11-30 08:56:20 25 4
gpt4 key购买 nike

我不确定从什么时候开始,但在我的开发机器上使用 AWS SDK with Java 时出现以下错误:

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

我可以上传文件,所以凭据似乎没问题,但我似乎没有下载它。我正在使用游戏!运行 JDK 1.7 和 AWS SDK 1.9.22 的框架 (1.2.7)。

这可能是什么原因?

最近我确实从 JDK 1.6 切换到 1.7,因为 1.6 与 AWS 的签名问题。我(还)没有在我的生产服务器上安装它,所以它可能与 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));

最佳答案

这与 CloudStack 和 SDK 版本有关。我降级到 1.8.11,一切正常!

关于java - Amazon S3 AWS 开始给出错误代码 400,原因不明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28704167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com