I would like to move a small image from one server to another (both are executed by node). When I search, I have not found enough. This post remains unanswered.
When I started experimenting, I wrote the following to the first server:
app.post("/move_img", function(req, res) { console.log("post handled"); fs.readFile(__dirname + "/img_to_move.jpg", function(err, data) { if (err) throw err; console.log(data); needle.post(server2 + "/post_img", { data: data, name : "test.jpg" }, function(result) { console.log(result); res.send("ok"); }); }); });
This part seems to work, since I can write data on the same server (using fs.writeFile), recreate img.
Now when I try to process the message on another server, I have a problem.
Server2:
app.post('/post_img', [ multer({ dest: './uploads/images'}), function(req, res) { console.log("body ",req.body)
Thus, I get an empty object in the files and in the body: { 'headers[Content-Type]': 'application/x-www-form-urlencoded', 'headers[Content-Length]': '45009' }
I think I could use busboy as an alternative, but I can't get it to work. Any advice, tutorials would be welcome.
cs04iz1
source share