cjFileBlob
仮想ファイルシステムからファイルを読み取る
CheerpJ仮想ファイルシステムからファイルを読み取るために使用されます。
async function cjFileBlob(path: string): Promise<Blob>;
パラメーター
- path (
string
) - 読み取るファイルへのパス。/files/
、/app/
、または/str/
で始まる必要があります。
戻り値
cjFileBlob
は、ファイル内容のBlob に解決されるPromise
を返します。
例
テキストファイルの読み取り
const blob = await cjFileBlob("/files/file1.txt");const text = await blob.text();console.log(text);
バイナリファイルの読み取り
const blob = await cjFileBlob("/files/file2.bin");const data = new Uint8Array(await blob.arrayBuffer());console.log(data);