Properties:
Name | Type | Description |
---|---|---|
name |
String |
The name of the file or directory |
type |
String |
The MIME type of the file (not defined for directories) |
size |
String |
The size of the file (not defined for directories) |
url |
String |
The direct file URL (not defined for directories) |
path |
String |
The directory path (not defined for files) |
filePath |
String |
The file path (not defined for directories) |
isDirectory |
Boolean |
The attribute which is only "true" for directories |
isFile |
Boolean |
The attribute which is only "true" for files |
list |
Array.<module:DriveManager~FileSystemEntry> |
The list of the child entries - files or directories (not defined for files) |
Example
import Agent from '@meldcx/agent';
const agent = new Agent();
const init = async() => {
await agent.onReadyAsync();
const fileContents = new TextEncoder('utf8').encode(JSON.stringify({test: 'file'})).buffer;
const drive1 = await agent.DriveManager.getDrive('drive1', {createIfNotFound: true});
await drive1.fileSystem.createFile('/folder1/folder2/file.json', fileContents, 'application/json');
const result = await drive1.fileSystem.getDirectory('/');
console.log(result);
//
// Will Print
// {
// "isFile": false,
// "isDirectory": true,
// "name": "ed6a4862-e6a9-4f74-a9d2-04e24d42ad5a",
// "path": "drive://drive1/",
// "list": [
// {
// "isFile": false,
// "isDirectory": true,
// "name": "folder1",
// "path": "drive://drive1/folder1",
// "list": [
// {
// "isFile": false,
// "isDirectory": true,
// "name": "folder2",
// "path": "drive://drive1/folder1/folder2",
// "list": [
// {
// "url": "http://127.0.0.1:9090/filesystem/html5/virtual-drives/ed6a4862-e6a9-4f74-a9d2-04e24d42ad5a/folder1/folder2/file.json",
// "size": 15,
// "type": "application/json",
// "isFile": true,
// "isDirectory": false,
// "name": "file.json",
// "filePath": "drive://drive1/folder1/folder2/file.json",
// }
// ]
// }
// ]
// }
// ]
// }
//
};
init();