title: 'Permission Denied' when getting images on S3 from Grails
body: <p>I have a grails 2.1.1 app that is accessing images stored in a bucket on s3, which I am accessing using the Grails-AWS plugin.</p>
  
  <p>Everything works fine when I use "grails run-app" and the server is localhost:8080/myApp.  I can put and get files with no problem.</p>
  
  <p>But when I deploy the war file to Amazon Elastic Beanstalk I get the following error when trying to get an image:</p>
  
  <pre><code> java.io.FileNotFoundException: 90916.png (Permission denied)
  
  at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:209)
  
  at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:160)
  
  at com.sommelier.domain.core.MyDomainObject.getPicture(MyDomainObject.groovy:145)
  </code></pre>
  
  <p>Here is my code for getting the image that is initiating the error:</p>
  
  <pre><code>    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 &lt;&lt; new URL(url).openStream()
      out.close()
  
      return imageFile        
  
  }
  </code></pre>
  
  <p>I have set the permissions on my s3 bucket as wide open as I can. I have used the "Add more permissions" button and added every possible option.</p>
  
  <p>Here is my bucket policy:</p>
  
  <pre><code>{
  "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/*"
      }
  ]
   }
  </code></pre>
  
  <p>And my CORS configuration:</p>
  
  <pre><code>&lt;CORSConfiguration&gt;
  &lt;CORSRule&gt;
      &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;
      &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt;
      &lt;MaxAgeSeconds&gt;3000&lt;/MaxAgeSeconds&gt;
      &lt;AllowedHeader&gt;Authorization&lt;/AllowedHeader&gt;
  &lt;/CORSRule&gt;
   &lt;/CORSConfiguration&gt;
  </code></pre>
  
  <p>Any thoughts?  Is this a S3 permissions problem, or is there something else?</p>