I have a small script to delete files from S3 when an object is deleted from the database. I do this with these lines:
$s3 = Storage::disk('s3');
$s3->delete('property/'.$id.'.jpg');
But sometimes the file is not in S3 anymore, but when that is the case I get an error FileNotFoundException in Filesystem.php line 383. File not found at path: property/11108.jpg
And of course with an error like this, the script halts.
What is the best way to first check if the file exists and if so delete it?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire