AWSCredentials myCredentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
AmazonS3 s3Client = new AmazonS3Client(myCredentials);
S3Object object = new S3Object();
object.setBucketName(existingBucketName);
String keyName = (storePath + "/" + file.getName()).replaceAll("//", "/");
object.setKey(keyName);
List<PartETag> partETags = new ArrayList<PartETag>();
log.debug("Step 1 Start");
// Step 1: Initialize.
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(existingBucketName, keyName);
InitiateMultipartUploadResult initResponse = s3Client.initiateMultipartUpload(initRequest);
log.debug("Step 1 End");
最后3行抛出的错误如下: -
[DEBUG][2016/10/04 12:19:17] Sending Request: POST https://bucketname.s3.amazonaws.com /files%2Fsns%2F201610%2FAer_24.xml Parameters: (uploads: null, ) Headers: (Content-Type: application/x-www-form-urlencoded; charset=utf-8, )
[DEBUG][2016/10/04 12:19:18] Received error response: Status Code: 403, AWS Service: null, AWS Request ID: 8B, AWS Error Code: InvalidAccessKeyId, AWS Error Message: The AWS Access Key Id you provided does not exist in our records., S3 Extended Request ID: fIBtP5w=
Status Code: 403, AWS Service: Amazon S3, AWS Request ID: 8B0B, AWS Error Code: InvalidAccessKeyId, AWS Error Message: The AWS Access Key Id you provided does not exist in our records., S3 Extended Request ID: fIP5w=
[ERROR][2016/10/04 12:19:18] The AWS Access Key Id you provided does not exist in our records.
Status Code: 403, AWS Service: Amazon S3, AWS Request ID: 8BB, AWS Error Code: InvalidAccessKeyId, AWS Error Message: The AWS Access Key Id you provided does not exist in our records., S3 Extended Request ID: fI5w=
注意: - 我可以在cloudberry的帮助下以相同的信誉登录到存储桶。