此程式碼片段會將 Response
寫入到特定路徑的磁碟中。Bun 將會根據其 Content-Type
標頭來使用 Response
body。
它使用快速的 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()
的完整文件。