plz i'm somehow lost here , i'm new in aws so i've installed aws-sdk-php in myproject , and i'm trying to test the upload ; here is the peace of code of the script :
require '.vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
// Instantiate an S3 client
$s3 = S3Client::factory(array(
'credentials' => array(
'key' => 'key ... ',
'secret' => 'secret key ... ',
)
));
$file_name = $_FILES['file']['tmp_name'];
try {
$s3->putObject(array(
'Bucket' => 'bucket_name',
'Key' => $_FILES['file']['name'],
'Body' => fopen($file_name, 'r'),
'ACL' => 'public-read',
));
echo " upload succed !!";
} catch (S3Exception $e) {
echo "There was an error uploading the file.\n";
echo $e->getMessage() . "\n";
}
this code is working fine from a local test , but when trying to do test the same script in a project in a folder in s3 ; i get this error :
There was an error uploading the file. Access Denied
any idea plz ? thanks.
Aucun commentaire:
Enregistrer un commentaire