Here is my function to upload to S3 using PHP. I get this error:
The request signature we calculated does not match the signature you provided. Check your key and signing method.
I'm using the correct key and secret. What have i done wrong?
function upload_s3bucket($file,$name,$bucket) {
require(APPPATH.'/third_party/aws/aws-autoloader.php');
$key = "*******";
$secret = "************";
$file = "/var/www/vhosts/example.com/website/assets/media/images/test.jpg";
if(isset($file)){
$s3 = new Aws\S3\S3Client([
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => $key,
'secret' => $secret,
]
]);
$result = $s3->putObject([
'Bucket' => 'cdn-example.com/'.$bucket,
'Key' => $key,
'SourceFile' => $file,
'ACL' => 'public-read'
]);
return $file_name;
}
}
Is the Object Key the same as Access Key? I'm using Access Key that i created from "Your Security Credentials".