Get file directory info
- 18 May 2022
- 1 Minute to read
- DarkLight
- PDF
Get file directory info
- Updated on 18 May 2022
- 1 Minute to read
- DarkLight
- PDF
Article Summary
Given a local filesystem path, get information about the file/directory it points to.
Since a path can be either a file or a directory, the Type output argument resolves to either file
or directory
.
Correspondingly, File or Directory will be a null value.
Input arguments
Label | Key | Type | Required? | Default | Description |
---|---|---|---|---|---|
File path | path | String(local-filesystem-reference) | Yes | – | Absolute local filesystem path to a file/directory. |
Output arguments
Number of outputs: 2
Label | Key | Type | Description |
---|---|---|---|
Type | type | String | Type of item at the given path |
File | file | Object | Object describing the file at the given path, if found. |
| file.path | String | Absolute local filesystem path representing the file location on the device, including the filename and extension. On web, this is created via the [`createObjectURL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) method. |
| file.mimeType | String | MIME type of the file, if it could be determined. |
| file.name | String | Name of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already. |
| file.size | Number | Size of the file, in bytes. |
| file.createdAt | String | Creation datetime of the file, if it can be determined. |
| file.modifiedAt | String | Datetime when the file was last modified, if it can be determined. |
Directory | directory | Object | Object describing the directory at the given path, if found. |
| directory.path | String | Absolute local filesystem path representing the directory location on the device. |
| directory.name | String | Name of the directory in the local filesystem, if applicable. Note that the directory name is included in the **Local path** property. |
| directory.files | Array | List of objects representing the files in the directory. |
| directory.directories | Array | List of objects describing subdirectories of the directory. |
| directory.totalSize | Number | Total size of the directory, in bytes. |
Events
No events.
Errors
Label | Code | Description |
---|---|---|
File/directory not found | fileNotFound | Thrown if a file/directory could not be found at the given path. |
Was this article helpful?