我有一个grails 2.1.1应用程序,它正在访问使用Grails-AWS插件访问的s3存储区中存储的图像。从Grails上获取S3上的图像时'权限被拒绝'
当我使用“grails run-app”并且服务器是localhost:8080/myApp时,一切正常。我可以放置并获取没有问题的文件。
但是,当我将WAR文件部署到Amazon弹性魔豆,我得到试图获取图像时出现以下错误:
java.io.FileNotFoundException: 90916.png (Permission denied)
at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
at com.sommelier.domain.core.MyDomainObject.getPicture(MyDomainObject.groovy:145)
这里是我让正在启动的错误形象代码:
File getPicture() {
def url = aws.s3().on("mybucket").url(image, "myfoldername")
File imageFile = new File(image)
def fileOutputStream = new FileOutputStream(imageFile)
def out = new BufferedOutputStream(fileOutputStream)
out << new URL(url).openStream()
out.close()
return imageFile
}
我已经将我的s3存储桶的权限设置为尽可能敞开。我使用了“添加更多权限”按钮并添加了每个可能的选项。
这里是我的斗政策:
{
"Version": "2008-10-17",
"Id": "Policy1355414697022",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mybucket/*"
},
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::mybucket/*"
}
]
}
而且我CORS配置:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
有什么想法?这是一个S3权限问题,还是有其他的东西?
我觉得这个临客:https://forums.aws.amazon.com/message.jspa?messageID = 205071可能会有所帮助。只是不确定。 – coderLMN