cjFileBlob

Read a file from the virtual filesystem

Used to read files from the CheerpJ virtual filesystem.

async function cjFileBlob(path: string): Promise<Blob>;

Parameters

  • path (string) - The path to the file to be read. Must begin with /files/, /app/ or /str/.

Returns

cjFileBlob returns a Promise which resolves to a Blob of the file contents.

Examples

Read a text file

const blob = await cjFileBlob("/files/file1.txt");
const text = await blob.text();
console.log(text);

Read a binary file

const blob = await cjFileBlob("/files/file2.bin");
const data = new Uint8Array(await blob.arrayBuffer());
console.log(data);