In order to send photos to node-js, I use this code here:
... request.post({ url: 'https://host.net', data: { note: 'Photo', file: fs.createReadStream('path/to/b101.jpg'), filename: 't100.jpg', }, }, function(error, response, body) { console.log("BODY: " + body); console.log("RESPONSE: " + JSON.stringify(response) ); }); ... But it happens to me very often that the photos are in the buffer, without local storage, like:
var photoBuffer = Buffer.from([255,216,255,224,0,16,74,70,73,70,0,1,1,0,0,1,0,1,0,0,255,254,0,59,67,82,69,65,84 ...]); How can I convert Buffer-to-Stream and send this stream or just a buffer to the server?
At the moment, I get either an empty stream or an error before the mandrel. In the case of an empty stream, I see that MSJ comes to the server, tk. in response code = 200.
Maybe there are some restrictions on the server side?