Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel s3 check if directory exists.

Tags:

laravel

How would I check with Laravel storage if a directory exists?

In the documentation there is only documented how to check if a file exists.

Storage::disk('local')->exists('file.jpg');

https://laravel.com/docs/5.3/filesystem#retrieving-files

like image 617
Jamie Avatar asked Oct 24 '16 11:10

Jamie


People also ask

How to check directory exists in Laravel?

Note: The File::isDirectory() function is used to check whether or not the given path exists.

What is storage path in laravel?

Laravel's filesystem configuration file is located at config/filesystems.php . Within this file, you may configure all of your filesystem "disks". Each disk represents a particular storage driver and storage location.


1 Answers

None of the answers here seems to answer specifically to check if a particular folder exists in S3. This is what I use and it works:

Storage::disk('s3')->exists('FOLDER_NAME')

The above will return a boolean. The above check works for both folders and filenames.

like image 136
Neel Avatar answered Sep 18 '22 01:09

Neel