0.93.0 • Published 7 years ago
multer-sftp-linux v0.93.0
multer-sftp-linux
SFTP storage engine for Multer Based entirle on multer-sftp but with added functionality for remote linux backends.
Install
$ npm install --save multer-sftp-linuxUsage
var multer = require('multer')
var sftpStorage = require('multer-sftp-linux')
var storage = sftpStorage({
sftp: {
host: '127.0.0.1',
port: 22,
username: 'username',
password: 'password'
},
destination: function (req, file, cb) {
cb(null, '/tmp/my-uploads')
},
filename: function (req, file, cb) {
cb(null, file.fieldname + '-' + Date.now())
}
})
var upload = multer({ storage: storage })API
var sftpStorage = require('multer-sftp')sftpStorage(opts)
The module returns a function that can be invoked with options to create a Multer storage engine.
opts
{
sftp: Object,
destination: function (req, file, cb) { return cb(null, '/path/to/uploads') }
filename: function (req, file, cb) { return cb(null, 'filename.ext') }
}sftp: Required.sftpis a settings object for sftp client connection. Please see ssh2 documentation for details.destination: Required.destinationis used to determine within which folder the uploaded files should be stored. This can also be given as astring(e.g.'/tmp/uploads').filename: Optional.filenameis used to determine what the file should be named inside the folder. If nofilenameis given, each file will be given a random name that doesn't include any file extension.
License
MIT © Chun-Kai Wang