【发布时间】:2018-05-04 10:09:47
【问题描述】:
目前我的用例是我的node.js 服务器Server A 需要创建一个CSV 文件,然后将该CSV 发送到另一个服务器Server B,它只接受application/octet-stream。
目前我正在手动将 csv 卷曲以将其上传到服务器 B。
curl -H "Content-Type:application/octet-stream"
-X PUT https://someexample.com/url/what/not
--upload-file newlyCreated.csv
但我需要自动执行上面的 curl 并想使用 node.js,因为服务器 A 是在 node.js 中构建的。我的直觉引导我使用流,但我似乎无法让它发挥作用。
fs.createReadStream('/path/to/csv').pipe(httpRequestToServerB)
然后响应客户端并发送一个成功的JSON
【问题讨论】:
标签: node.js http stream httprequest octetstring