Closed sigmaSd closed 1 year ago
With fetch I can do
const imageFile = Deno.createSync(imagePath);
await fetch(imageUrl).then((r) => r.body?.pipeTo(imageFile.writable));
but request doesn't seem to expose body in the response
Good idea! There will be a pipeToPath
method in the next release along with pipeTo
and pipeThrough
methods.
thanks really cool!
what about making pipeToPath defaults to figuring out the path from the url url.pathname.split('/').at(-1)
I think wget act like this?
I was wondering about it too and it seems reasonable. The one thing I wasn't sure about was what to do for a path that's just a domain like https://deno.land
(so /
)... I think in those cases it should just throw? Would you like to open a PR for that? Otherwise I can get to it soon.
I'm not sure about the idea either, the current api you implemented is very clear though, maybe we give it some time and wait for more interesting use cases?
I ended up implementing it in #59
Nice
Maybe it could be another override to request
the advantage it would skip loading the file into memory while keeping the cool progress bar