How to read files
Use the storage manager to read files from a disk.
Small Files
The read() method is ideal for reading small files (less than 10KB):
import { Storage } from 'typefs';
async function readFile() {
const path = 'file.txt';
const content = await Storage.disk('assets').read(path);
}
Large File
readStream() is a more memory efficient method, as it can read large files in chunks:
Example
import { Storage } from "typefs";
async function readLargeFile() {
const fileStream = await Storage.disk("tmp").readStream("video.mp4");
}