检索所有带有内容的存储文件

时间:2019-05-17 14:04:07

标签: laravel s3-bucket laravel-filesystem laravel-storage

我正在尝试获取所有带有文件的文件夹,它的内容来自laravel中的存储/应用/文件夹。 有什么解决方案吗?

这是我所做的,它工作正常,但花费太多时间。

$main_code_folder = [];
$folder_name = 'folder';
$folder_list = Storage::directories($folder_name);   
foreach ($folder_list as $sub_folder) {
   $sub_folder_name = str_replace($folder_name . "/", "", $sub_folder);
   $sub_folder_files = Storage::files($sub_folder);
   foreach ($sub_folder_files as $file) {
       $sub_file_name = str_replace($folder_name . "/" . $sub_folder_name . "/", "", $file);
        if (!isset($main_code_folder[$sub_folder_name][$sub_file_name])) {
          $main_code_folder[$sub_folder_name][$sub_file_name] = Storage::get($file);
        }
    }
}

0 个答案:

没有答案