title: AWS S3 : access denied to object while "bucket block public access" is off
body: <p>I am new to AWS. I am saving file to AWS from my Java Application. The file is being saved in the bucket, no problem with that. But the real problem is starting when trying to access them. Every time getting :</p>
  <pre><code>This XML file does not appear to have any style information associated with it. The document tree is shown below.
  &lt;Error&gt;
  &lt;Code&gt;AccessDenied&lt;/Code&gt;
  &lt;Message&gt;Access Denied&lt;/Message&gt;
  &lt;RequestId&gt;8B350BEBBDF0386B&lt;/RequestId&gt;
  &lt;HostId&gt;77cB7pybpshSC7TfDilGiPHvKfd91wI24iQJ8ach7jLIBuqOeB+hfDz7soLE1p0ZqrUyoRqgPCw=&lt;/HostId&gt;
  &lt;/Error&gt;
  </code></pre>
  <p>I have checked the AWS setting, both my bucket and object is public. I have searched in the internet, most of the solution is talking about make ACL public, I think i already did that.</p>
  <p><strong>Bucket Policy:</strong></p>
  <pre><code>{
      &quot;Version&quot;: &quot;2008-10-17&quot;,
      &quot;Id&quot;: &quot;PolicyForCloudFrontPrivateContent&quot;,
      &quot;Statement&quot;: [
          {
              &quot;Sid&quot;: &quot;Allow-OAI-Access-To-Bucket&quot;,
              &quot;Effect&quot;: &quot;Allow&quot;,
              &quot;Principal&quot;: &quot;*&quot;,
              &quot;Action&quot;: &quot;s3:GetObject&quot;,
              &quot;Resource&quot;: &quot;arn:aws:s3:::xxxxxxxbucket/*&quot;
          },
          {
              &quot;Sid&quot;: &quot;Allow-Public-Access-To-Bucket&quot;,
              &quot;Effect&quot;: &quot;Allow&quot;,
              &quot;Principal&quot;: &quot;*&quot;,
              &quot;Action&quot;: &quot;s3:GetObject&quot;,
              &quot;Resource&quot;: &quot;arn:aws:s3:::xxxxxxxbucket/*&quot;
          },
          {
              &quot;Sid&quot;: &quot;Access-to-specific-VPCE-only&quot;,
              &quot;Effect&quot;: &quot;Deny&quot;,
              &quot;Principal&quot;: &quot;*&quot;,
              &quot;Action&quot;: &quot;s3:GetObject&quot;,
              &quot;Resource&quot;: &quot;arn:aws:s3:::xxxxxxxbucket/*&quot;,
              &quot;Condition&quot;: {
                  &quot;StringNotEquals&quot;: {
                      &quot;aws:sourceVpce&quot;: &quot;vpce-1a2b3c4d&quot;
                  }
              }
          }
      ]
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xGWCN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xGWCN.png" alt="account level public access." /></a></p>
  <p><a href="https://i.stack.imgur.com/efDmh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/efDmh.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/J0NFC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J0NFC.png" alt="Object Level ACL public access." /></a></p>
  <p><a href="https://i.stack.imgur.com/6az2G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6az2G.png" alt="Bucket is public" /></a></p>
  <p>While permission has given to public, i am understanding why it is giving Access Denied Error.</p>