我需要在aws上设置我的图像,我已经把我的bucket配置为公共的,但我只是得到了 "AccessDenied"
public boolean saveImage(String nome, String base64){
try {
byte[] imageBytes = Base64.getDecoder().decode(base64.split(",")[1]);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageBytes));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "png", baos);
byte[] bytes = baos.toByteArray();
String fileName = nome+".png";
BasicAWSCredentials awsCreds = new BasicAWSCredentials(acessKey, secretKey);
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileName, new ByteArrayInputStream(bytes), new ObjectMetadata());
AmazonS3 s3Client =
AmazonS3ClientBuilder.standard().withRegion("sa-east-1")
.withCredentials(new
AWSStaticCredentialsProvider(awsCreds))
.build();
s3Client.putObject(putObjectRequest);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;