Download file fetch response






















Stream response to file using Fetch API and fs. Asked 4 years, 5 months ago. Active 3 years, 2 months ago. Viewed 9k times. I want to use the native Fetch API because the request module would be a big overhead. Add a comment. Active Oldest Votes. I got it working. I made a function which transforms the response into a readable stream.

This loads the whole content of the file in memory Ihor Sakailiuk Ihor Sakailiuk 4, 3 3 gold badges 21 21 silver badges 26 26 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Who is building clouds for the independent developer? Exploding turkeys and how not to thaw your frozen bird: Top turkey questions Featured on Meta.

January 30, Reactjs Leave a comment. Questions: React 0. Examples will be appreciated. Questions: This is my gulpfile code: gulp. Add menu. I see that the "onDownloadComplete" is called synchronously after submit, are you just making the assumption that there aren't any errors and that the server receives the request? Himmel Yes, sadly, this work around does not provide a way to confirm the file download was successful.

One possible solution could be to send an Ajax request prior to the download in Widget. Then, if successful, trigger the download. You still aren't confirming the download is successful, but if the file doesn't exist or there's some kind of network error at that time, you could handle the error. You might also want to look into putting the form in an iframe and read the iframe's content using the onload event.

This is causing me to redirect. Anton Philin Anton Philin 3 3 silver badges 2 2 bronze badges. The downloadjs is excellent and perfectly solved the problem. Stan Stan 1, 11 11 silver badges 12 12 bronze badges. U just saved my 2 days of searcing efforts This is the answer I am looking for — saikumar. This worked for me. Community Bot 1 1 1 silver badge. Raluca Popa Raluca Popa 92 4 4 bronze badges. Jose Jose 1, 13 13 silver badges 17 17 bronze badges.

I think that this is the most simple and clean answer. No need to generate "fake" actions. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.



0コメント

  • 1000 / 1000