I couldn't upload image to S3 via Spring Boot application deployed on Amazon Elastic Beanstalk with the following method :
@Autowired
private AmazonS3Client amazonS3Client;
amazonS3Client.setEndpoint(S3_REGION_ENDPOINT);
amazonS3Client.putObject(new PutObjectRequest(S3_BUCKET_NAME, key, fileToUpload));
The log showed the following error:
Caused by: java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:1012)
at com.g2m.persistence.image.service.FileArchiveService.convertFromMultiPart(FileArchiveService.java:91)
at com.g2m.persistence.image.service.FileArchiveService.saveFileToS3(FileArchiveService.java:44)
But when trying to upload image using local endpoint (running Spring Boot locally), I managed to successfully upload the image to S3 as well as retrieving it.
Any idea how this issue can be solved? It has something to do with S3 permission or nothing at all?