I'm trying to send as formData
, a stream from an image I get using request
The problem is that the request is fire after the formData
request.
Is there any way I can pipe the image request to recognize? but with the freedom of adding parameters to the formData
?
e.g:
var req = request({
method: 'POST',
url: 'http://www.foo.bar/api/v1/tag/recognize',
formData: {
image_file: request('http://visual-recognition-demo.mybluemix.net/images/horses.jpg'),
param2: 'value2'
},
json: true,
});
How do I fire:
request('http://visual-recognition-demo.mybluemix.net/images/horses.jpg')
so the response can be used in req
UPDATE: Seems like the Content-Length
header is missing in the
http://visual-recognition-demo.mybluemix.net/images/horses.jpg response
and you only get Transfer-Encoding: chunked
More details here
request
library would allow you to this via piping but instead you'd just have to use a callback with the body returned from the original request. – Gambellcontent-length
in the first response – Spillman