I need use S3 to save file using sdk java

0

private AmazonS3 s3; private BasicAWSCredentials awsCreds; private Bucket bucket; private String nomeBucket = null;

// @SuppressWarnings("deprecation") public OperacoesS3() { try { // chave geral awsCreds = new BasicAWSCredentials("AKIA5FTZDHH2SGNA6OFU", "1UXd7Okp8BAkrc+0i/wEqMGgh4DjeuzXKDyeozWo"); AWSStaticCredentialsProvider awsscp = new AWSStaticCredentialsProvider(awsCreds); s3 = AmazonS3ClientBuilder.standard().withCredentials(awsscp).withRegion(Regions.US_EAST_1).build(); } catch (Exception e) { e.printStackTrace(); }

private void execEnviarModelo() { try { OperacoesS3 s3 = new OperacoesS3(); String destinoArquivo = "20230813_095738.jpg"; String origemArquivo = "C:\Users\rutra\OneDrive\Área de Trabalho\20230813_095738.jpg"; s3.enviarArquivo(destinoArquivo, origemArquivo, 0L); } catch (Exception e) { e.printStackTrace(); } }

I receive this error: com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 7YV83CDKHM5EPWKP; S3 Extended Request ID: Xv3Hz68osBS9wD0E86Vyrfl+a7fLtUeMidSjQ599m3f724zJqaFHyTAyfiKET07ITurFh+hHXTo=; Proxy: null), S3 Extended Request ID: Xv3Hz68osBS9wD0E86Vyrfl+a7fLtUeMidSjQ599m3f724zJqaFHyTAyfiKET07ITurFh+hHXTo=

I dó know where is my mistake./

  • Can you tell us how you were able to resolve this issue so that others could benefit from the solution

asked 14 days ago29 views
2 Answers
1

Check IAM Permissions:

Ensure the IAM user or role associated with the AWS credentials has s3:PutObject permissions for the S3 bucket.

Review Bucket Policy:

Verify that the S3 bucket policy does not explicitly deny the s3:PutObject action for the user or role.

profile pictureAWS
EXPERT
Deeksha
answered 14 days ago
profile picture
EXPERT
reviewed 14 days ago
0
Accepted Answer

Hi I found my error Thanks

answered 14 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions