Currently I have to get all elements of a path and check if the original path matches the path of the current $item. This is inefficient and I don't know if there is a way to get the file or directory directly through a listContent($path).
$contents=$filesystem->listContents(dirname($ruta))->toArray();
foreach ($contents as $item) {
if ($item['path']==$ruta || str_replace('\\', '/',$item['path']) == $ruta) { // /a/b/c.txt == /a/b/c.txt
if ($item instanceof FileAttributes) {
return new FileAttributes($ruta,$item->fileSize(),$item->visibility(),$item->lastModified(),$item->mimeType(),$item->extraMetadata());
} elseif ($item instanceof \League\Flysystem\DirectoryAttributes) {
return new DirectoryAttributes($ruta,$item->visibility(),$item->lastModified(),$item->extraMetadata());
}
}
}
Question
Hello, is there any way to get the json of a single item? example:
Currently I have to get all elements of a path and check if the original path matches the path of the current $item. This is inefficient and I don't know if there is a way to get the file or directory directly through a listContent($path).