Skip to content

要將 ReadableStream 寫入磁盤,首先從流創建一個 Response 實例。然後可以使用 Bun.write() 將此 Response 寫入磁盤。

ts
const stream: ReadableStream = ...;
const path = "./file.txt";
const response = new Response(stream);

await Bun.write(path, response);

請參閱 文檔 > API > File I/O 獲取 Bun.write() 的完整文檔。

Bun學習網由www.bunjs.com.cn整理維護