此程式碼片段會將一個 Response
寫入磁碟中的特定路徑。Bun 會根據其 Content-Type
標頭使用 Response
主體。
它使用快速的 Bun.write()
API 來有效率地將資料寫入磁碟。第一個引數是 目的地,例如絕對路徑或 BunFile
執行個體。第二個引數是要寫入的 資料。
const result = await fetch("https://bun.dev.org.tw");
const path = "./file.txt";
await Bun.write(path, result);
請參閱 文件 > API > 檔案 I/O 以取得 Bun.write()
的完整文件。