Multer-sftp module is not including in the server script and after running server script i am getting timeout error.

const express = require('express');
const multer = require('multer');
const sftpStorage = require('multer-sftp');
const cors = require('cors');
const app = express();


var storage = sftpStorage({
  sftp: {
    host: 'host',
    port: '21',
    username: 'username',
    password: 'Password'
  destination: function (req, file, cb) {
    return cb(null, 'images')

  filename: function (req, file, cb) { return cb(null, + '-' + file.originalname) }
const upload = multer({ storage: storage }); 

app.use(cors());'/upload', upload.single('image'), (req, res) => {
  if (req.file)
      imageUrl: `images/${req.file.filename}`
    res.status("409").json("No Files to Upload.")

const PORT = 5000;

console.log('api runnging on port: ' + PORT);

Solution i wanted is i need to upload files to remote server using ReactJS. It would be good if some one help me to solve this.

0 Answers