I'm having a hard time getting the S3 upload to work. My goal is to:
I was unable to successfully read from the .aws/credentials file, so I'm hard coding my access/secret key for now. This is my script where it stands. What am I doing wrong here?
UploadCSS.php:
<?php
require '/vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$buckets = array();
$css_dir = "../css/";
$client = S3Client::factory(
array(
'key' => "MyAccessKeyAsAQuotedString",
'secret' => "MySecretKeyAsAQuotedString"
)
);
echo "Scanning $css_dir
";
$files = scandir($css_dir);
foreach ($files as $file) {
$success = false;
$ext = (string) end(explode('.', $file));
if ($ext == "css") {
$buckets[] = $file;
}
}
foreach ($buckets as $key => $bucket) {
echo "Uploading $bucket
";
try {
$result = $client->putObject(array(
'Bucket' => $bucket, //EDITED
'Key' => "sharedcss/$bucket" ,
'SourceFile' => "../css/$bucket"
));
$client->waitUntil('ObjectExists', array(
'Bucket' => $this->bucket,
'Key' => 'data_from_file.txt'
));
} catch (S3Exception $e) {
echo $e->getMessage();
}
}
Errors:
Fatal error: Uncaught exception 'Guzzle\Common\Exception\RuntimeException' with message 'The PHP cURL extension must be installed to use Guzzle.' in /scripts/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php:72
Stack trace:
#0 /scripts/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php(76): Guzzle\Http\Client->__construct('https://s3.amaz...', Object(Guzzle\Common\Collection))
#1 /scripts/vendor/aws/aws-sdk-php/src/Aws/Common/Client/ClientBuilder.php(247): Aws\Common\Client\AbstractClient->__construct(Object(Aws\Common\Credentials\Credentials), Object(Aws\S3\S3Signature), Object(Guzzle\Common\Collection))
#2 /scripts/vendor/aws/aws-sdk-php/src/Aws/S3/S3Client.php(211): Aws\Common\Client\ClientBuilder->build()
#3 /scripts/AmazonAWS/scripts/UploadCSS.php5(18): Aws\S3\S3Client::factory(Array)
#4 {main}
thrown in /scripts/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php on line 72
Thank you in advance!