title: How Read and write public file into Amazon S3?
body: <p>I'm trying to write and download the file to Amazon S3. The file is loaded but I can not get it back:</p>
  
  <pre><code>public function putFile() 
  {
      $url = 'https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/p720x720/12631558_953568381347717_3978737099026165391_n.jpg?oh=9e14f5ea6f8e3a3fc8ffa07095d4c766&amp;oe=57321C9D&amp;__gda__=1463610491_c1f275837b7f5b4d2041597a3d7bb9c8';        
      $file = file_get_contents($url);
  
      $s3 = Storage::disk('s3');
      $s3-&gt;put('file.jpg', $file);        
  }
  
  public function getFile() 
  {
       $contents = $s3-&gt;get('file.jpg');        
       dd($contents);
  }
  </code></pre>
  
  <p>getFile() return:</p>
  
  <pre><code>    FileNotFoundException in FilesystemAdapter.php line 58:
      file.jpg
  </code></pre>
  
  <p>my Bucket permission:</p>
  
  <pre><code>    Grantee: mgalex (List, Update/Delete, View Permissions, Edit Permissions)
      Grantee: Any Authentificated AWS User (List, Update/Delete, View Permissions)
      Grantee: Everyone (List, Update/Delete, View Permissions)
  </code></pre>
  
  <p>But file is created with permissions:</p>
  
  <pre><code>    Grantee: mgalex (Open/Download, View Permissions, Edit Permissions)
  </code></pre>
  
  <p>I edited <a href="https://aws.amazon.com/ru/blogs/aws/amazon-s3-cross-origin-resource-sharing/" rel="nofollow">CORS</a>. I tried to resolve it. Problem still exists</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"&gt;          
      &lt;CORSRule&gt;
          &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;
          &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt; 
          &lt;AllowedMethod&gt;POST&lt;/AllowedMethod&gt;
          &lt;AllowedMethod&gt;DELETE&lt;/AllowedMethod&gt;
          &lt;AllowedHeader&gt;*&lt;/AllowedHeader&gt;       
      &lt;/CORSRule&gt;
  &lt;/CORSConfiguration&gt;
  </code></pre>
  
  <p>IMPORTANT: If I set up manually permission to file "Any Authentificated AWS User" or "Everyone", the code works.</p>
  
  <p>EDIT 2: I tried to upload a file in another way and added ACL into request (<a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl" rel="nofollow">canned ACL</a>)</p>
  
  <pre><code>public function putFile2() 
  {
      $bucket = config('filesystems.disks.s3.bucket');
      $fileName = 'file2.jpg';
  
      $url = 'https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/p720x720/12631558_953568381347717_3978737099026165391_n.jpg?oh=9e14f5ea6f8e3a3fc8ffa07095d4c766&amp;oe=57321C9D&amp;__gda__=1463610491_c1f275837b7f5b4d2041597a3d7bb9c8';        
      $fileBody = file_get_contents($url);
  
      $disk = Storage::disk('s3');
      $client = $disk-&gt;getDriver()-&gt;getAdapter()-&gt;getClient();
  
      $client-&gt;putObject([
          'Bucket' =&gt; $bucket,
          'Key'    =&gt; $fileName,
          'Body'   =&gt; $fileBody,
          'ACL'    =&gt; 'public-read-write'
      ]);
  }
  </code></pre>
  
  <p>This return error: AccessDenied.</p>
  
  <p>I have 2 questions:</p>
  
  <ol>
  <li>Why can not I get a file from the code, if I connect to S3 with the correct key?</li>
  <li>How to write the file to the server by making it public available (Grantee: Everyone)? Is it possible?</li>
  </ol>
  
  <p>Please, help. I am looking for answers for a long time and have not solved the problem</p>