I am putting a object in my AWS S3 basket by using following code.
$temp = explode(".", $_FILES["file"]["name"]);
$_FILES["file"]["name"] = $newfilename = round(microtime(true)) . '.' . end($temp);
$filepath = $_FILES['file']['tmp_name'];
try {
$result = $this->Amazon->S3->putObject(array(
'Bucket' => 'mytest.sample',
'ACL' => 'authenticated-read',
'Key' => 'files/image/' . $id . '/' . $newfilename,
'ServerSideEncryption' => 'aws:kms',
'SourceFile' => $filepath,
'ContentType' => mime_content_type($filepath),
));
} catch (S3Exception $e) {
echo $e->getMessage() . "\n";
}
and it is working fine. files are uploading but when I try to delete the file empty response I am getting. here is the code used for deleting object.
try {
$result = $this->Amazon->S3->deleteMatchingObjects(array(
'Bucket' => 'mytest.sample',
//'Key' => 'files/image/' . $id . '/' . $fileName['Attachment']['attachment'],
'Key' => 'files/image/45/1441026402.docx', //static path for checking.
'VersionId' => 'latest',
));
} catch (S3Exception $e) {
echo $e->getMessage() . "\n";
}
I tried below method too
try {
$result = $this->Amazon->S3->deleteObject(array(
'Bucket' => 'mytest.sample',
//'Key' => 'files/image/' . $id . '/' . $fileName['Attachment']['attachment'],
'Key' => 'files/image/45/1441026402.docx',
'VersionId' => 'latest',
));
} catch (S3Exception $e) {
echo $e->getMessage() . "\n";
}
Is there any permission issue?
Aucun commentaire:
Enregistrer un commentaire