1

i m trying to upload a file local server to remote server, but am getting issue with upload a file into remote server also in my below code not getting error too.

var multer = require('multer')
var sftpStorage = require('multer-sftp')

var storage = sftpStorage({
  sftp: {
    host: 'ip address',
    port: '22',
    username: 'xxxxxxxxxx',
    password: 'yyyyyyyyy'
  },
  destination: function (req, file, cb) {
    return cb(null, '/home/g457b5jxaq4m/public_html/shiva')
  },

  filename: function (req, file, cb) { return cb(null, '/home/sivaprakash/Desktop/cre.txt') }
})

var upload = multer({ storage: storage })

please kindly check my code and let me know if any mistake.

Sivaprakash D
  • 318
  • 1
  • 4
  • 17
  • Please check whether the `port` => `22` is open or not – David R Aug 03 '18 at 05:45
  • Also try changing your `var upload = multer({ storage: storage })` statement as `var upload = multer({ storage: storage }).array('file');` – David R Aug 03 '18 at 05:47
  • What kind of error are you getting? Are there any logs for it? – MiKr13 Aug 03 '18 at 05:58
  • @MihirKumar i did not get any error as of now. there is no log file created in the server. – Sivaprakash D Aug 03 '18 at 06:05
  • @DavidR thanks for your suggesstion, still the file not getting uploading in the server. yes the port no 22 is opened. i can able to upload fiel using https://preview.npmjs.com/package/ssh2-sftp-client library not with the multer-sftp. – Sivaprakash D Aug 03 '18 at 06:08
  • Thanks All, now I can upload a file in remote server. but I have another query now, if possible to change the destination path. If yes please let me know how I can achieve that please. – Sivaprakash D Aug 12 '18 at 11:07

0 Answers0