我正在使用Amazon S3存储桶上传我的图像。我收到了来自Google的警告邮件,说我的AWS凭证已公开。所以现在我要替换代码,并使用Amazon Cognito。
我无法访问该存储桶。该错误表明访问被拒绝。
这是我的代码:
credentialsProvider = new CognitoCachingCredentialsProvider(
context, // get the context for the current activity
"xxxxxxx", // your AWS Account id
"ap-southeast-1:3d4e113d-4cd3-47ac-b5ef-xxxxxxxxxx", // your identity pool id
"arn:aws:iam::xxxxxxxxx:role/Cognito_trackusersUnauth_Role",// an authenticated role ARN
"arn:aws:iam::xxxxxxxxx:role/Cognito_trackusersAuth_Role", // an unauthenticated role ARN
Regions.AP_SOUTHEAST_1 //Region
);
s3 = new AmazonS3Client(credentialsProvider);
s3.setEndpoint("s3-ap-southeast-1.amazonaws.com");
这是拒绝访问的地方:
List<Bucket> buckets = s3.listBuckets();