Directory
class Directory
A virtual directory of the non-tabular files in a file index table (or in query results with a file_id variable), reflecting the folder structure of the files' paths. Directories can be navigated, listed, and downloaded.
Constructors
Table.toDirectory([options])
Return the root Directory of a file index table's files.
Query.toDirectory([options])
Return the root Directory of the files referenced by a query's results.
Directory.get(path)
Return a subdirectory (or File) of a directory.
Directory.list([maxResults, options])
List the subdirectories and Files of a directory.
Examples
const table = redivis.table('demo.example_data_files:yz1s:v1_3.example_file_types:4c10');
const directory = await table.toDirectory();
directory.list(); // The files and directories at the root
directory.list({ mode: 'files', recursive: true }); // Every file
const file = directory.get('path/to/file.txt'); // Returns null if there's no such file
const subdirectory = directory.get('path/to/');
// Download all files to the provided path (Node.js only)
await directory.download('/download/path');Attributes
name
The directory's name (an empty string for the root directory).
path
The directory's absolute path, e.g. /images/2024. The root directory's path is /.
parent
The parent Directory, or undefined for the root directory.
children
A Map of the directory's immediate children (Files and Directories), keyed by name.
table
The Table that the files belong to, if any.
query
The Query that the files belong to, if any.
Methods
Directory.download([path, options])
Download all files in the directory, recreating its structure (Node.js only).
Directory.get(path)
Return the File or Directory at a path, or null if it doesn't exist.
Directory.list([maxResults, options])
List the directory's files and subdirectories.
Was this helpful?

