title: How to make all Objects in AWS S3 bucket public by default?
body: <p>I am using a PHP library to upload a file to my bucket. I have set the ACL to <strong>public-read-write</strong> and it works fine but the file is still private.</p>
  <p>I found that if I change the <strong>Grantee to Everyone</strong> it makes the file public. What I want to know is how do I make the <strong>default Grantee on all objects</strong> in my bucket to be set to <strong>&quot;Everyone&quot;</strong>. Or is there another solution to <strong>make files public</strong> by default?</p>
  <p>Code I am using is below:</p>
  <pre class="lang-php prettyprint-override"><code>public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array()) {
      if ($input === false) return false;
      $rest = new S3Request('PUT', $bucket, $uri);
  
      if (is_string($input)) $input = array(
          'data' =&gt; $input, 'size' =&gt; strlen($input),
          'md5sum' =&gt; base64_encode(md5($input, true))
      );
  
      // Data
      if (isset($input['fp']))
          $rest-&gt;fp =&amp; $input['fp'];
      elseif (isset($input['file']))
          $rest-&gt;fp = @fopen($input['file'], 'rb');
      elseif (isset($input['data']))
          $rest-&gt;data = $input['data'];
  
      // Content-Length (required)
      if (isset($input['size']) &amp;&amp; $input['size'] &gt;= 0)
          $rest-&gt;size = $input['size'];
      else {
          if (isset($input['file']))
              $rest-&gt;size = filesize($input['file']);
          elseif (isset($input['data']))
              $rest-&gt;size = strlen($input['data']);
      }
  
      // Custom request headers (Content-Type, Content-Disposition, Content-Encoding)
      if (is_array($requestHeaders))
          foreach ($requestHeaders as $h =&gt; $v) $rest-&gt;setHeader($h, $v);
      elseif (is_string($requestHeaders)) // Support for legacy contentType parameter
          $input['type'] = $requestHeaders;
  
      // Content-Type
      if (!isset($input['type'])) {
          if (isset($requestHeaders['Content-Type']))
              $input['type'] =&amp; $requestHeaders['Content-Type'];
          elseif (isset($input['file']))
              $input['type'] = self::__getMimeType($input['file']);
          else
              $input['type'] = 'application/octet-stream';
      }
  
      // We need to post with Content-Length and Content-Type, MD5 is optional
      if ($rest-&gt;size &gt;= 0 &amp;&amp; ($rest-&gt;fp !== false || $rest-&gt;data !== false)) {
          $rest-&gt;setHeader('Content-Type', $input['type']);
          if (isset($input['md5sum'])) $rest-&gt;setHeader('Content-MD5', $input['md5sum']);
  
          $rest-&gt;setAmzHeader('x-amz-acl', $acl);
          foreach ($metaHeaders as $h =&gt; $v) $rest-&gt;setAmzHeader('x-amz-meta-'.$h, $v);
          $rest-&gt;getResponse();
      } else
          $rest-&gt;response-&gt;error = array('code' =&gt; 0, 'message' =&gt; 'Missing input parameters');
  
      if ($rest-&gt;response-&gt;error === false &amp;&amp; $rest-&gt;response-&gt;code !== 200)
          $rest-&gt;response-&gt;error = array('code' =&gt; $rest-&gt;response-&gt;code, 'message' =&gt; 'Unexpected HTTP status');
      if ($rest-&gt;response-&gt;error !== false) {
          trigger_error(sprintf(&quot;S3::putObject(): [%s] %s&quot;, $rest-&gt;response-&gt;error['code'], $rest-&gt;response-&gt;error['message']), E_USER_WARNING);
          return false;
      }
      return true;
  }
  </code></pre>