title: Make AWS s3 directory public using php
body: <p>I know there is no concept of folders in S3, it uses a flat file structure. However, i will use the term "folder" for the sake of simplicity.</p>
  
  <p><strong>Preconditions:</strong> </p>
  
  <ul>
  <li>An s3 bucket called foo</li>
  <li>The folder foo has been made public using the AWS Management Console</li>
  <li>Apache</li>
  <li>PHP 5</li>
  <li>Standard AWS SDK</li>
  </ul>
  
  <p><strong>The problem:</strong></p>
  
  <p>It's possible to upload a folder using the AWS PHP SDK. However, the folder is then only accessible by the user that uploaded the folder and not public readable as i would like it to be. </p>
  
  <p><strong>Procedure:</strong></p>
  
  <pre><code>$sharedConfig = [
      'region'  =&gt; 'us-east-1',
      'version' =&gt; 'latest',
      'visibility' =&gt; 'public',
      'credentials' =&gt; [
          'key'    =&gt; 'xxxxxx',
          'secret' =&gt; 'xxxxxx',
      ],
  ];
  
  // Create an SDK class used to share configuration across clients.
  $sdk = new Aws\Sdk($sharedConfig);
  
  // Create an Amazon S3 client using the shared configuration data.
  $client = $sdk-&gt;createS3();
  
  $client-&gt;uploadDirectory("foo", "bucket", "foo", array(
              'params'      =&gt; array('ACL' =&gt; 'public-read'),
              'concurrency' =&gt; 20,
              'debug'       =&gt; true
          ));
  </code></pre>
  
  <p><strong>Success Criteria:</strong></p>
  
  <p>I would be able to access a file in the uploaded folder using a "static" link. Fx:</p>
  
  <pre><code>https://s3.amazonaws.com/bucket/foo/001.jpg
  </code></pre>