I provide the route in my express application, which provides the contents of the cloud file as a download. I have access to the input stream of a cloud file, and I would like to transfer it directly to the response output stream. However, I am using express, which does not seem to support the input stream.
I was hoping I could do this:
res.send (cloudInputStream);
but it does not work. Express' sends a body or buffer, but apparently not an input stream.
In this case, I would like to set the headers using res.setHeader (), then access the raw output stream, and then:
cloudInputStream.pipe (responseOutputStream);
Is it possible?
Alternatively, I could turn the input stream into a buffer and provide this buffer for sending. However, it reads the entire contents of the cloud file in memory at a time, which I would like to avoid.
Any thoughts?
source share