Saving stream response as a downloaded file

Hi, I have a following problem, and I don’t really know how to chew on it. I make json requests (via affjax) to a Haskell backend and one of the endpoints returns a StreamPost response. Ideally, I would like to be able to save that response to a file - so that when the user clicks a button, the file gets saved the same way as if he clicked some link to the pdf on a webpage. Does Affjax even support such streamed-payload, or do I have to load the whole payload to the memory? Files can be quite big (up to 1-2GB). Or perhaps I should use another library to handle that?

I use halogen for UI, if that’s relevant for the question.

1 Like

Ok, I observed the memory consumption of my Chrome browser during download to the Blob object, and it seems that the file is loaded to the physical memory - RAM consumption does not peak, only disk usage (perhaps it could also be a matter of gzip accept-encoding, idk).