When I look at the code behind fs.createReadStream()
, it calls new ReadStream() and passes the path/url to that. On this line of code, it appears that the only type of url that is supported is a file URL. The doc is silent on that topic which is why I went and looked at the code. So, it does not appear to me that fs.createReadStream()
supports that type of pseudo-URL.
Since you just want a readstream from that URL and you have the actual URL of the remote resource, I would suggest you just use either http.get()
or request()
or something similar as those will all contact the remote host and return to you a readStream. Since your objective was to get a readStream, this is one way to achieve that.
http.get('http://localhost:3000/dabe5cdd-00cc-408a-9f3d-b0ba5f2b10b3', (res) => {
// res is a readstream here
}).on('error', (err) => {
// error on the request here
});
FYI, you may find this answer on Blob URLs to be useful. I don't see any evidence that fs.createReadStream()
supports blob URLs. In the browser, they are something created only by the internals of the browser and are only useful within that specific web page context (they refer indirectly to some internal storage) and can't be passed outside the web page or even preserved from one web page to the next. If you wanted your server to have access to the actual data from a blob URL created in the browser, you'd have to upload the actual data to your server. Your server can't access a blob URL created in the browser.
fs.readStream()
, it callsnew ReadStream()
and passes the path/url to that. On this line of code, it appears that the only type of url that is supported is a file URL. The doc is silent on that topic which is why I went and looked at the code. – Desrochersblob:http://localhost:3000/dabe5cdd-00cc-408a-9f3d-b0ba5f2b10b3
so I'm not sure what to do with it. If it's a remote resource, then you can just usehttp.get()
orrequest()
on the actual URL and you'll have a readStream from that. – Desrochersblob:http://localhost:3000/dabe5cdd-00cc-408a-9f3d-b0ba5f2b10b3
is the blob address for a webcam video I did in my browser – Circumvallate