gpt4 book ai didi

java - 使用 Amazon s3 Java SDK 的异常

转载 作者:搜寻专家 更新时间:2023-11-01 03:11:00 28 4
gpt4 key购买 nike

<分区>

我正在尝试使用 Java SDK 将文件上传到 s3。该代码在我运行 jdk1.6.0_26 的 Windows 7 机器上运行良好,但在服务器上运行时,Ubuntu Server 10.04 with Java(TM) SE Runtime Environment (build 1.7.0-b147),出现以下错误来自 https://github.com/amazonwebservices/aws-sdk-for-java/blob/master/src/main/java/com/amazonaws/auth/AbstractAWSSigner.java :

com.amazonaws.AmazonClientException: Unable to calculate a request signature: null Stack trace : com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:71)
com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:55)
com.amazonaws.services.s3.internal.S3Signer.sign(S3Signer.java:101)
com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:234)
com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:169)
com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2597)
com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1025)

对 s3 的调用:

AWSCredentials c = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3Client client = new AmazonS3Client(c);
String key = station + "/" + file.getName();
client.putObject(new PutObjectRequest(bucket, key, file));

我是 Java 的新手,不确定如何进一步排除故障。

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