0

I am developing one web application in which server is stored in different Azure server and front-end is also stored in different one. When I try to use multer in node js to store URL to front-end server it always returns that path is not found.when I saw the error log it I found this

Error: ENOENT: no such file or directory, open 'D:\home\site\wwwroot\http:\nomadiccare-portal.azurewebsites.net\images\undefined.png' at Error (native)

Here is my source code for node js which is working perfectly on localhost.

 var uploadImageURL="http://nomadiccare-portal.azurewebsites.net/images/";
 var currentClientId;
 var storage = multer.diskStorage({
     destination: function (request, file, callback) {
            callback(null, uploadImageURL);
     },
     filename: function (request, file, callback){
      console.log("It Is In"+file);
      callback(null,currentClientId+".png");
     }
  });
var upload = multer({ storage: storage });

How can I remove D:\home\site\wwwroot\ from URL?

2 Answers2

0

destination of DiskStorage is used to determine within which folder the uploaded files should be stored. It must be the path of the disk rather than a URL of the website.

If the other server has a post route to upload a file, you can make a post request with the file data from your server after you saved the file successfully. Refer to this you can learn how to send HTTP post request from a server to another server with data in Node.js.

Aaron Chen
  • 9,835
  • 1
  • 16
  • 28
0
var storage = multer.diskStorage({
  destination: uploadImageURL, // change here
  filename: function (request, file, callback) {
    console.log('It Is In' + file)
    callback(null, currentClientId + '.png')
  }
})
Beat
  • 4,386
  • 2
  • 35
  • 52