Files
mixyboos/src/lib/utils/httpUtils.ts
2023-07-04 19:50:52 +01:00

16 lines
344 B
TypeScript

///
// synchronous file downloader for use in tests
///
import fs from "fs";
import fetch from "node-fetch";
const downloadFile = async (url: string, path: string) => {
const response = await fetch(url);
const bytes = await response.arrayBuffer();
fs.writeFileSync(path, Buffer.from(bytes));
return path;
};
export { downloadFile };