You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
929 B

  1. var request = require('request');
  2. function postImage(fileImg) {
  3. url = "http://127.0.0.1:3050/image";
  4. //var fileImg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
  5. var fileImg = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
  6. var importFile = function(aux, fileImg) {
  7. var decodedFile = new Buffer(fileImg, 'base64');
  8. var r = request.post(url, function(err, httpResponse, body) {
  9. if (err) {
  10. console.log(err);
  11. }
  12. console.log(body);
  13. console.log(aux);
  14. });
  15. var form = r.form();
  16. form.append('file', decodedFile, {
  17. filename: 'temp.png'
  18. });
  19. return (r);
  20. }
  21. a = importFile("a",fileImg);
  22. }
  23. postImage("girada.png");