Я пытаюсь загрузить файлы на Amazon S3, но он возвращает эту ошибку:
com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 26B9B4844CEA580C), S3 Extended Request ID: S0Ds3cvubCSZTAd1ESUG5rMRifGLHRAHBviyUHzDVI5W8FQxtRDMBNSrhVme6K86UryWxqORv30=
Я уже настроил IAM и корзину на AWS, и я использую хороший доступ / секрет ( тот, который aws дал мне). В чем проблема? Спасибо!
Код клиента S3:
s3client = AmazonS3ClientBuilder
.standard()
.withRegion(Regions.CA_CENTRAL_1) // The first region to try your request against
.withForceGlobalBucketAccessEnabled(true) // If a bucket is in a different region, try again in the correct region
.withCredentials(AWSStaticCredentialsProvider(BasicAWSCredentials(accessKey, secretKey)))
.build()
Код загрузки файла:
private fun uploadFileTos3bucket(fileName: String, file: File) {
s3client.putObject(PutObjectRequest(bucketName, fileName, file)
.withCannedAcl(CannedAccessControlList.PublicRead))
}
IAM пользователь:
![enter image description here](https://i.stack.imgur.com/rcb8z.png)
S3 разрешения: ![enter image description here](https://i.stack.imgur.com/GBWLO.png)