You are trying to return a "multi-page HTTP response" with an HTML part and another part (file). After a quick research, I'm not sure that such a thing exists, and if it does the way it is supported / implemented in browsers.
In a slightly different way, to respond to the "classic" HTML response, which was then to launch a second request - an XHR call when loading a document, for example, to start downloading a file.
On the server side, you will need to save the contents of the file, I am not very familiar with Heroku, but I think you could use a key value, for example Redis, or even a dedicated service, such as Amazon S3.