import fs from '@microart/fs';
// use like regular, simply proxies to internal nodejs 'fs' module
fs.readdirSync();
The file system class is where the magic of the library comes from. It allows you to setup all sorts of providers to retrieve files and information.
import { FileSystem } from '@microart/fs';
const { fs } = new FileSystem();
const { fs } = new FileSystem({
provider: example provider instance
});
import { LocalProvider } from '@microart/fs';
const { fs } = new FileSystem({
provider: new LocalProvider({
root: './', // maps '/' to whatever './' is
})
});
// Regular
fs.readdirSync('/');
// home, boot, etc, mnt, var, usr, root, lib
// FileSystem with root mapped to './'
fs.readdirSync('/');
// index.js, node_modules
import { ProxyProvider } from '@microart/fs';
const { fs } = new FileSystem({
provider: new ProxyProvider({
getItems() {
return [
{
name: "Test Folder",
type: "folder",
getItems() {
return [];
}
}
]
}
})
});
fs.readdirSync('/');
// Test Folder
import { S3Provider } from '@microart/fs';
const { fs } = new FileSystem({
provider: new S3Provider({
endpoint: '',
region: '',
accessKey: '',
accessSecret: '',
})
});
fs.readdirSync('/');
// folder1, test-folder2, examplefolder
import { FTPProvider } from '@microart/fs';
const { fs } = new FileSystem({
provider: new FTPProvider({
host: '',
port: '',
username: '',
password: '',
})
});
fs.readdirSync('/');
// folder1, test-folder2, examplefolder