此代码用于列出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));
}