title: AWS S3 Permissions - Access Denied ON GetObjectUrl PHP
body: <p>putObject works well for me. But when I do a getObjectURL s3 responds with an Access Denied. Looked into different ways to set the policy, etc. Still no luck. Any help appreciated!</p>
  
  <p>putObject code: </p>
  
  <pre><code>$this-&gt;load-&gt;library('aws');
  
  $temporary_png_path = tempnam(sys_get_temp_dir(), 'sig') . $upload_data['file_ext'];
  
  $document_s3_key = 'profile_pictures/'.$user-&gt;id.'/profile_'.$user-&gt;id.$upload_data['file_ext'];
  
  $resource = fopen($upload_data['full_path'], 'r');
  
  try{
      $aws_object=$this-&gt;aws-&gt;putObject(array(
          'Bucket'      =&gt; 'tbucket',
          'Key'         =&gt; $document_s3_key,
          'SourceFile'  =&gt; $resource,
          'Body' =&gt; $resource,
          'ContentType' =&gt; 'image/jpeg'
      ));
  }
  catch (Exception $e)
  {
      $error = "Something went wrong saving your file.\n".$e;
      echo $error;
  }
  </code></pre>
  
  <p>getObjectURL code:</p>
  
  <pre><code>$this-&gt;load-&gt;library('aws');
  $profile_image = $this-&gt;aws-&gt;getObjectUrl('tbucket', 'profile_pictures/'.$user-&gt;id.'/'.'profile_'.$user-&gt;id.'.jpeg');
  $this-&gt;data['image'] = ($profile_image == '')? "/public/images/avatar-large.jpg" : $profile_image;
  </code></pre>
  
  <p>AWS Permissions:</p>
  
  <pre><code>Authenticated Users =&gt; All Permissions enabled
  </code></pre>
  
  <p>Bucket Policy:</p>
  
  <pre><code>    {
      "Version": "2008-10-17",
      "Id": "Policynumber",
      "Statement": [
          {
              "Sid": "Stmtnumber",
              "Effect": "Allow",
              "Principal": {
                  "AWS": "arn:aws:iam::number:user/t_master"
              },
              "Action": [
                  "s3:GetObjectAcl",
                  "s3:GetObjectTorrent",
                  "s3:GetObjectVersion",
                  "s3:GetObjectVersionAcl"
              ],
              "Resource": "arn:aws:s3:::tbucket/*"
          }
      ]
  }
  </code></pre>