mercredi 30 novembre 2016

Delete file from S3 using Laravel app

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?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2gJcLM5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire