Retrieve the contents of a file from your MFS.
Optional
options: Partial<CatOptions>for await (const buf of fs.cat('/foo.txt')) {
console.info(buf)
}
Change the permissions on a file or directory in your MFS
Optional
options: Partial<ChmodOptions>await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
const beforeStats = await fs.stat('/foo.txt')
await fs.chmod('/foo.txt', 0x755)
const afterStats = await fs.stat('/foo.txt')
console.info(beforeStats)
console.info(afterStats)
Add a file or directory to a target directory in your MFS.
await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
await fs.mkdir('/bar')
await fs.cp('/foo.txt', '/bar')
Copy a file from one place to another in your MFS.
await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
await fs.cp('/foo.txt', '/bar.txt')
List directory contents from your MFS.
for await (const entry of fs.ls('/bar')) {
console.info(entry)
}
Make a new directory in your MFS.
Optional
options: Partial<MkdirOptions>await fs.mkdir('/new-dir')
Return statistics about a UnixFS DAG in your MFS.
Optional
options: Partial<StatOptions>await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
const stats = await fs.stat('/foo.txt')
console.info(stats)
Update the mtime of a UnixFS DAG in your MFS.
Optional
options: Partial<TouchOptions>await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
const beforeStats = await fs.stat('/foo.txt')
await fs.touch('/foo.txt')
const afterStats = await fs.stat(afterCid)
console.info(beforeStats)
console.info(afterStats)
Add a stream of Uint8Array
to your MFS as a file.
Optional
options: Partial<WriteOptions>import fs from 'node:fs'
const stream = fs.createReadStream('./foo.txt')
await fs.writeByteStream(stream, '/foo.txt')
Add a single Uint8Array
to your MFS as a file.
Optional
options: Partial<WriteOptions>await fs.writeBytes(Uint8Array.from([0, 1, 2, 3]), '/foo.txt')
The MFS interface allows working with files and directories in a mutable file system.