title: Amazon S3 copyObject using PHP
body: <p>I am trying to copy a 1TB file from one bucket to another. I know that this can be done easily if I log into the AWS S3 panel but I would like to do it using PHP.</p>
  
  <p>I am using the following <a href="https://github.com/tpyo/amazon-s3-php-class/" rel="nofollow">AWS S3 class from github</a></p>
  
  <pre><code>public static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array(), $storageClass = self::STORAGE_CLASS_STANDARD)
      {
          $rest = new S3Request('PUT', $bucket, $uri, self::$endpoint);
          $rest-&gt;setHeader('Content-Length', 0);
          foreach ($requestHeaders as $h =&gt; $v) $rest-&gt;setHeader($h, $v);
          foreach ($metaHeaders as $h =&gt; $v) $rest-&gt;setAmzHeader('x-amz-meta-'.$h, $v);
          if ($storageClass !== self::STORAGE_CLASS_STANDARD) // Storage class
              $rest-&gt;setAmzHeader('x-amz-storage-class', $storageClass);
          $rest-&gt;setAmzHeader('x-amz-acl', $acl);
          $rest-&gt;setAmzHeader('x-amz-copy-source', sprintf('/%s/%s', $srcBucket, rawurlencode($srcUri)));
          if (sizeof($requestHeaders) &gt; 0 || sizeof($metaHeaders) &gt; 0)
              $rest-&gt;setAmzHeader('x-amz-metadata-directive', 'REPLACE');
  
          $rest = $rest-&gt;getResponse();
          if ($rest-&gt;error === false &amp;&amp; $rest-&gt;code !== 200)
              $rest-&gt;error = array('code' =&gt; $rest-&gt;code, 'message' =&gt; 'Unexpected HTTP status');
          if ($rest-&gt;error !== false)
          {
              self::__triggerError(sprintf("S3::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s",
              $rest-&gt;error['code'], $rest-&gt;error['message']), __FILE__, __LINE__);
              return false;
          }
          return isset($rest-&gt;body-&gt;LastModified, $rest-&gt;body-&gt;ETag) ? array(
              'time' =&gt; strtotime((string)$rest-&gt;body-&gt;LastModified),
              'hash' =&gt; substr((string)$rest-&gt;body-&gt;ETag, 1, -1)
          ) : false;
      }
  </code></pre>
  
  <p>I am using it in my PHP code as follows:</p>
  
  <pre><code>$s3 = new S3(AWS_ACCESS_KEY, AWS_SECRET_KEY);
  $s3-&gt;copyObject($srcBucket, $srcName, $bucketName, $saveName, S3::ACL_PUBLIC_READ_WRITE);
  </code></pre>
  
  <p>I'm getting no error_log. What am I doing wrong that I am missing, please?</p>