Laravel s3检查目录是否存在。(Laravel s3 check if directory exists.)

编程入门 行业动态 更新时间:2024-10-04 07:26:54
Laravel s3检查目录是否存在。(Laravel s3 check if directory exists.)

如果目录存在,我将如何检查Laravel storage ?

在文档中,只记录了如何检查文件是否存在。

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

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

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

最满意答案

尝试在父目录中获取目录列表,并检查您要查找的目录是否在数组中:

in_array('directoryYoureLookingFor', Storage::disk('s3')->directories('parentDirectory'));

我刚检查过,这个解决方案适用于Laravel 5.3。

Try to get directories list in a parent directory and check if the directory you're looking for is in an array:

in_array('directoryYoureLookingFor', Storage::disk('s3')->directories('parentDirectory'));

I've just checked and this solution works in Laravel 5.3.

更多推荐

本文发布于:2023-07-09 10:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085571.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是否存在   目录   Laravel   directory   check

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!