我无法通过部署在Amazon Elastic Beanstalk上的Spring Boot应用程序将图片上传到S3,方法如下:
@Autowired
private AmazonS3Client amazonS3Client;
amazonS3Client.setEndpoint(S3_REGION_ENDPOINT);
amazonS3Client.putObject(new PutObjectRequest(S3_BUCKET_NAME, key, fileToUpload));
日志显示以下错误:
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)
但是当尝试使用本地端点上传图像时(在本地运行Spring Boot ),我成功地将图像上传到S3并检索到它。
你知道如何解决这个问题吗?这跟S3权限有什么关系,还是什么都没有?
发布于 2017-05-17 19:32:42
在我看来,您没有正确地实例化S3客户端。能否检查实例化时是否提供了正确的凭据?
就像这样
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
amazonS3Client = new AmazonS3Client(credentials);
https://stackoverflow.com/questions/44021260
复制相似问题