Currently my usecase is my node.js
Server Server A
needs to create a CSV file then send that CSV to another Server Server B
which only accepts application/octet-stream
.
Currently I'm manually CURLing the csv to upload it to Server B.
curl -H "Content-Type:application/octet-stream"
-X PUT https://someexample.com/url/what/not
--upload-file newlyCreated.csv
But I need to automate the curl above and wanted to use node.js
since Server A is built in node.js
. My instincts leads me to use streams but I can't seem to make it work.
fs.createReadStream('/path/to/csv').pipe(httpRequestToServerB)
Then respond to client and send a JSON that it is successful