Skip to content

Commit

Permalink
Add fallback.xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
gmanriqueUy committed Dec 6, 2023
1 parent 7c13d26 commit 3526fea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/seed/downloadFile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { fetch } from "@remix-run/node";
import { readFile } from "fs/promises";

const URL =
"https://www5.ine.gub.uy/documents/Estad%C3%ADsticasecon%C3%B3micas/SERIES%20Y%20OTROS/Cotizaci%C3%B3n%20de%20monedas/Cotizaci%C3%B3n%20monedas.xlsx";

export async function downloadFile() {
return (await fetch(URL)).arrayBuffer();
const response = await fetch(URL);

if (response.status === 200) {
return response.arrayBuffer();
}

console.log("File download failed. Reading fallback.xlsx");
return await readFile(__dirname + "/fallback.xlsx");
}
Binary file added scripts/seed/fallback.xlsx
Binary file not shown.

0 comments on commit 3526fea

Please sign in to comment.