The AWS SDK for PHP should be somewhat easy to use, once you have figured out the composer stuff. This article covers some of the errors we encountered when using the AWS S3 for the first time.
Hopefully it will be helpful for someone else who is learning to use the SDK.
PermanentRedirectThe bucket you are attempting to access....
This can happen if you haven't specified a Region in your factory method, otherwhise you may get strange errors from the AWS. I.e.
PermanentRedirectThe bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
You can set your region using the factory method of the SDK. I.e.
$client = S3Client::factory(array( 'key' => '', 'secret' => '', 'region' => 'eu-west-1', ));
Note. According to the documentation, the region looks like: us-east-1, us-west-1, us-west-2, eu-west-1, and so on. You should use whatever correspond to your own region.
SignatureDoesNotMatch, Status Code: 403....
You may encounter this problem if your credentials does not match those provided. I.e.
The request signature we calculated does not match the signature you provided. Check your key and signing method.
Make sure you entered the correct key and secret and try again. The error you are getting might look like the below:
Fatal error: Uncaught Aws\S3\Exception\SignatureDoesNotMatchException: AWS Error Code: SignatureDoesNotMatch, Status Code: 403, AWS Request ID