Hi,
I'm fetching a zip file form a url and I want to save the blob into a local file:
fetch(downloadUrl, {
method: 'GET'
})
.then(response => response.blob())
.then(blob => {
console.log(blob.size)
// Save the blob to a file
})
any idea on how to save the blob?
Many thanks.
await Deno.writeFile("path/to/file", await blob.arrayBuffer())
Please use the discord first for help and questions: https://discord.gg/deno.
Thank you very much,
The provided solution does not work, it says: ArrayBuffer is not assignable to Uint8Array,
Anyway, i will switch to discord,
thank you again.
@fakoua I am not sure if your question was answered.
Just adding the solution, so if someone comes across, he can find the answer.
fetch(downloadUrl, {
method: 'GET'
})
.then(response => response.blob())
.then(blob => {
const buffer = await blob.arrayBuffer();
const unit8arr = new Deno.Buffer(buffer).bytes();
Deno.writeFileSync("path/to/file", unit8arr);
})
Most helpful comment
@fakoua I am not sure if your question was answered.
Just adding the solution, so if someone comes across, he can find the answer.