This code is used to list the directory from FTP folder. Does anyone know how to change the code to access the AWS S3 bucket directory? Because of that, AWD S3 is unable to use a glob function to list down the folder list.
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));
}