Registry / storage / multer-sftp

multer-sftp

JSON →
library1.1.1jsnpmunverified

SFTP storage engine for Multer (v1.1.1), enabling file uploads to an SFTP server via express/multer middleware. Requires peer dependency ssh2-sftp-client >=1.0.0. Ships TypeScript types. Compared to other multer storage engines (like multer-s3), it targets SFTP/SSH environments. Low maintenance cadence (last release ~2019).

npm install multer-sftp
INSTALL
IMPORT
SIG · MULTER-SFTP
M
multer-sftp
storagejavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sftpStorage
import sftpStorage from 'multer-sftp'
import { sftpStorage } from 'multer-sftp'
Default export only; named import will be undefined.
sftpStorage (CommonJS)
const sftpStorage = require('multer-sftp')
const { sftpStorage } = require('multer-sftp')
Destructuring CommonJS require mistakenly extracts property; use entire module.
multer
import multer from 'multer'
import multer from 'express'
Multer is a separate package; not part of express.

Configure multer with SFTP storage engine using environment variables for credentials.

import multer from 'multer'; import sftpStorage from 'multer-sftp'; const storage = sftpStorage({ sftp: { host: process.env.SFTP_HOST || 'localhost', port: parseInt(process.env.SFTP_PORT || '22', 10), username: process.env.SFTP_USER || 'user', password: process.env.SFTP_PASS || '' }, destination: (req, file, cb) => cb(null, '/uploads'), filename: (req, file, cb) => cb(null, file.fieldname + '-' + Date.now()) }); const upload = multer({ storage }); export default upload;
Debug
Known issues
breakingsftpStorage() requires opts.sftp object; if omitted or undefined, throws 'Cannot read property 'host' of undefined'.
fix
Ensure sftp object is provided with at least host/username/password.
affects: >=1.0.0
gotchadestination can be a string or function; if string, it's used directly. If omitted, files end up in undefined causing errors.
fix
Always provide destination (string or function).
affects: >=1.0.0
gotchafilename callback must include extension if desired; random name has no extension.
fix
Provide filename function that appends extension, e.g., cb(null, file.originalname).
affects: >=1.0.0
deprecatedPackage uses SSH2 library indirectly via ssh2-sftp-client; connection options are the same as ssh2 client methods.
fix
Refer to ssh2 documentation for connection options.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'host')
opts.sftp is missing or undefined.
fix
Provide sftp object with host, username, password.
Error: ENOENT: no such file or directory, open '/tmp/my-uploads/filename'
destination path does not exist on SFTP server.
fix
Ensure destination directory exists or use callback to create it before finalizing upload.
TypeError: storage.getFilename is not a function
Incorrect usage of multer storage API; sftpStorage does not expose getFilename.
fix
Use filename option in sftpStorage configuration, not in multer() call.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
ssh2-sftp-clientrequiredpeer dependency for SFTP client operations
multeroptionalrequired to use the storage engine
Agent activity
18 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
multer-sftp — npm install multer-sftp · libregistry