我怎样才能pipe图像file upload与superagent端点?

/** * Request png */ var request = require('superagent') var req = request.get('http://example.com/original/' + id + '.png'); req.end(function(response){ // Here i want send responsed image to another server req.post('http://upload-example.com').attach('???') }) 

我怎样才能pipe图像file upload端点? 我在nodejs env中使用最新版本的superagent。

Solutions Collecting From Web of "我怎样才能pipe图像file upload与superagent端点?"

attach可以设置Buffer。
但是,你需要使用filename选项。

这工作得很好。

 var request = require('superagent'); request.get('https://example.com/image.png') .end((err, res) => { // Here i want send responsed image to another server console.log(err, res.body); // body is Buffer request.post('http://upload-example.com') .attach('image', res.body, {filename: 'test.png'}) .end((err, res) => { console.log(err, res.statusCode); }); });