title: AWS PHP SDK upload file to S3 confusing errors
body: <p>Ok, so I have tried several methods of getting a file to upload to my S3 account. Finally found myself getting somewhere and BOOM - confusing documentation and strange error messages which appear to contradict themselves.</p>
  
  <p>Ok, to start with I am not using composer or anything like that, I am doing this the old fashioned way: </p>
  
  <pre><code>require '/path/to/aws-autoload.php';
  </code></pre>
  
  <p>Now this loads correctly, and I have trimmed down the autoload to only use Common and S3 classes - don't need everything!</p>
  
  <p>Next up I load the S3 Client and Credentials:</p>
  
  <pre><code>use Aws\S3\S3Client;
  use Aws\Common\Credentials\Credentials;
  </code></pre>
  
  <p>Now the code to start the magic happening:</p>
  
  <pre><code>$file = '/path/to/' . $filename;
  $credentials = new Credentials('KEY', 'SECRET KEY');
  $s3 = S3Client::factory(array('credentials' =&gt; $credentials));
  
  try{
  $s3-&gt;putObject(array(
      'Bucket' =&gt; 'sub.domain.com.s3.amazonaws.com',
      'Body'   =&gt; fopen($file, 'r'),
      'ACL'    =&gt; 'public-read',
  ));
  } catch (S3Exception $e) {
       $result = array(
           'ok' =&gt; false,
           'descr' =&gt; 'There was an error uploading the file to S3 : ' . $filename
       );
  }
  </code></pre>
  
  <p>The issue I seem to be having is with the 'Bucket' itself.</p>
  
  <p>When I format the Bucket as <strong>sub.domain.com</strong> I get the following message back from the AWS API:</p>
  
  <blockquote>
    <p>AWS Error Message: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint: "sub.domain.com.s3.amazonaws.com".</p>
  </blockquote>
  
  <p>Now when I change the 'Bucket' to match the above like so : <strong>sub.domain.com.s3.amazonaws.com</strong></p>
  
  <p>I get the following error message :</p>
  
  <blockquote>
    <p>AWS Error Message: The specified bucket does not exist</p>
  </blockquote>
  
  <p>Am I doing something wrong? Is something missing? Unfortunately the AWS Documentation is not quite up to scratch. The API seems to be contradicting itself at the moment. I know all the keys are correct, and all permissions are correct. It went from 301 - Redirect to 404 - Not Found from its own advice.</p>
  
  <p>Any help/advise would be greatly appreciated. I feel like I am going in circles a little here!</p>