AWS S3文件管理器目录

时间:2019-02-23 08:00:33

标签: php amazon-web-services amazon-s3

此代码用于列出FTP文件夹中的目录。有谁知道如何更改代码以访问AWS S3存储桶目录?因此,AWD S3无法使用全局功能来列出文件夹列表。

public function directory() {   
    $json = array();

    if (isset($this->request->post['directory'])) {
        $directories = glob(rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/') . '/*', GLOB_ONLYDIR); 

        if ($directories) {
            $i = 0;

            foreach ($directories as $directory) {
                $json[$i]['data'] = basename($directory);
                $json[$i]['attributes']['directory'] = utf8_substr($directory, strlen(DIR_IMAGE . 'data/'));

                $children = glob(rtrim($directory, '/') . '/*', GLOB_ONLYDIR);

                if ($children)  {
                    $json[$i]['children'] = ' ';
                }
                $i++;
            }
        }       
    }
    $this->response->setOutput(json_encode($json));       
}

0 个答案:

没有答案