javascript - with node.js, how to post image (take it from some url) to server API? -


i'm trying image url, , post somehow(either formdata)... i've found usefull info here 1, 2, 3 ... i've tried several variants of code. still cant' load image server. code :

var formdata = require('form-data'); var request = require('request');        var form = new formdata();          request.get(url, {encoding:null}, function (error, response, body) {               form.append('my_logo', body);              form.getlength(function(err,length){                  console.log(length);                  var r = request.post(upload_url, { headers: { 'content-length': length } }, function(err, httpresponse, body) {                       if (err) console.log(+err)                          var res = (typeof body == 'string') ? json.parse(body) : body;                      console.log(res);                   })                  r._form = form              });          }) 

in response post request receive information, loaded undefined... use request , form-data library... how right? maybe native node.js code better?


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -