Grails-AWS プラグインを使用してアクセスしている s3 のバケットに保存されている画像にアクセスする grails 2.1.1 アプリがあります。
「grails run-app」を使用し、サーバーが localhost:8080/myApp の場合、すべて正常に動作します。問題なくファイルを送受信できます。
しかし、war ファイルを Amazon Elastic Beanstalk にデプロイすると、イメージを取得しようとすると次のエラーが発生します。
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 のアクセス許可の問題ですか、それとも他に何かありますか?