초보자 인 S3입니다. 컴퓨터의 특정 파일을 저장하는 데 사용하고 싶습니다. 내 모든 파일과 폴더를 업로드 자바에있는 작은 프로그램을 작성 그러나 나는이 예외가 :Amazon S3에서 Java로 파일을 업로드 할 수 없습니다.
Infos: Received error response: Status Code: 403, AWS Request ID: F75DC5496B071F7D, AWS Error Code: SignatureDoesNotMatch, AWS Error Message: The request signature we calculated does not match the signature you provided. Check your key and signing method., S3 Extended Request ID: XtRqjEuUmygswUxFUophRudYKbwi4OY4MK9QnYS4DMrH6JrHZXihUEC4mLZbPqz4
Exception in thread "main" Status Code: 403, AWS Request ID: F75DC5496B071F7D, AWS Error Code: SignatureDoesNotMatch, AWS Error Message: The request signature we calculated does not match the signature you provided. Check your key and signing method., S3 Extended Request ID: XtRqjEuUmygswUxFUophRudYKbwi4OY4MK9QnYS4DMrH6JrHZXihUEC4mLZbPqz4
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:538)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:283)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:168)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2555)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1044)
at com.socialite.s3export.S3Export.parseDirectory(S3Export.java:89)
at com.socialite.s3export.S3Export.parseDirectory(S3Export.java:73)
at com.socialite.s3export.S3Export.parse(S3Export.java:48)
at com.socialite.s3export.S3Export.main(S3Export.java:122)
나는 내가 SDK에 올바른 자격 증명을 제공 확신합니다. 테스트 목적으로 이전 프로그램에서 사용한 것과 동일한 자격 증명을 사용했는데 효과적이었습니다. 버킷을 만들 수도 있지만 개체를 저장할 수 없습니다. 필자의 코드에서는 PutObjectRequest
을 사용하여 객체를 저장합니다.
AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(
S3Export.class .getResourceAsStream("AwsCredentials.properties")));
올리려 코드 :
private void parseDirectory(File fin, File fdefault, String out)
throws FileNotFoundException {
System.out.println("processing .." + fin.getName());
File[] files = fin.listFiles();
PrintWriter pw = new PrintWriter(fdefault);
for (File f : files) {
String key = UUID.randomUUID().toString();
String name = "";
PutObjectRequest por = null;
if (f.isDirectory()) {
name = "d_" + f.getName() + ".properties";
File metadata = new File(out + name);
parseDirectory(f, metadata, out);
pw.println(key + "=" + name);
//upload to s3
por = new PutObjectRequest(this.bucketName, key, metadata);
} else {
name = f.getName();
pw.println(key + "=" + name);
por = new PutObjectRequest(this.bucketName, key, f);
}
this.amazonS3.putObject(por);
}
pw.close();
}
내 코드는 다음 줄에 실패 this.amazonS3.putObject(por);
다음
내가 내 아마존 S3 개체를 초기화하기 방법입니다.
내 코드가 무엇이 잘못되었는지 설명 할 수 있습니까?
eclipse aws sdk를 사용하여 샘플 프로젝트를 생성하고 S3, SimpleDB 등의 상호 작용이 어떻게 작동하는지 확인할 수 있습니다. – Kris