I am using version 3.67.5 of AWS SDK PHP to upload files to S3. The code is in an Heroku dyno.
I've created the access keys, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, and set them as configuration variables in the Heroku instance. I know that they are there, because with getenv() I 've outputted them.
I'm using the following code:
- try {
- //Create a S3Client
- $s3Client = new S3Client([
- 'profile' => 'default',
- 'region' => 'some-region',
- 'version' => 'latest'
- ]);
- $result = $s3Client->putObject([
- 'Bucket' => 'some-bucket',
- 'Key' => $fileName,
- 'SourceFile' => $this->getParameter('photos_directory') . $fileName,
- ]);
- } catch (AwsException $e) {
- echo $e->getMessage() . "
- ";
- }
Still, uploading a file, it shows the following error:
request.CRITICAL: Uncaught PHP Exception Aws\Exception\CredentialsException: "Cannot read credentials from /app/.aws/credentials"
I've tested passing a new element 'credentials' in the constructor, like they do in theirs unit tests, and the error is the same.