Closing a file
How do I close a file after opening and streaming it?
My handler function code is as follows:
Is there a good way of closing the "file" after returning the "Response" object?
6 Replies
If you use
.readable
, it's closed after the whole body is read automatically
no need to manually close itoh, that's convenient
got it, thanks 👍
file.stat
appears to be a function that returns a promise now..
is there a way to get the file size in the same .then()
or do i have to chain another .then
?I would have personally written this like
async
/await
syntax is your friend!and then check only the file open for erros i think?
if you want to throw a better error, yes
got it, thanks a lot