我正在努力研究如何获取生成的子进程的输出并将该输出输入到多部分 mime 上传中。
据我所知,这是我所拥有的
var request = require('superagent');
var spawn = require('child_process').spawn;
var spawned = spawn('echo', ['hello', 'world']);
request.post('http://localhost/api/upload')
.attach('file', spawned.stdout)
.end(function(res) {
console.log("DONE", res);
});
不幸的是,这引发了Error: socket hang up
来自 Node.js 的相当无益的响应。