@ficsysfr/nestjs_module_factorydrive-sftp
v2.0.1
Published
SFTP driver for @ficsysfr/nestjs_module_factorydrive
Maintainers
Readme
SFTP driver for Factory drive module
SFTP driver for Factory drive module from NestJS framework
Installation
Install both packages with your favorite package manager.
# npm
npm install @ficsysfr/nestjs_module_factorydrive @ficsysfr/nestjs_module_factorydrive-sftp# yarn
yarn add @ficsysfr/nestjs_module_factorydrive @ficsysfr/nestjs_module_factorydrive-sftp# pnpm
pnpm add @ficsysfr/nestjs_module_factorydrive @ficsysfr/nestjs_module_factorydrive-sftp# bun
bun add @ficsysfr/nestjs_module_factorydrive @ficsysfr/nestjs_module_factorydrive-sftpConfigure a disk and register the driver
Declare the SFTP disk in FactorydriveModule.forRoot() (or forRootAsync()), then
register the sftp driver key in the module constructor. Disks are connected during
onModuleInit, after the driver has been registered.
import { Module } from '@nestjs/common'
import { FactorydriveModule, FactorydriveService } from '@ficsysfr/nestjs_module_factorydrive'
import { SFTPStorage } from '@ficsysfr/nestjs_module_factorydrive-sftp'
@Module({
imports: [
FactorydriveModule.forRoot({
default: 'remote',
disks: {
remote: {
driver: 'sftp',
config: {
root: '/var/www/storage',
options: {
host: 'sftp.example.com',
port: 22,
username: 'my-user',
password: process.env.SFTP_PASSWORD,
},
},
},
},
}),
],
})
export class AppModule {
public constructor(storage: FactorydriveService) {
storage.registerDriver('sftp', SFTPStorage)
}
}Example operations
const disk = this.storage.getDisk('remote')
// A string is written as file content.
await disk.put('documents/report.txt', 'Hello from SFTP storage')
const exists = await disk.exists('documents/report.txt')
const content = await disk.get('documents/report.txt')
console.log({ exists: exists.exists, content: content.content })Errors
SFTP failures are mapped to the Factorydrive exceptions: a missing file (SFTP status 2 /
ENOENT) raises FileNotFoundException, a denied access (SFTP status 3 / EACCES)
raises PermissionMissingException, and anything else raises UnknownException with the
original code. getStream() reports these errors on the returned stream.
Development
This repository uses Yarn 1.22.22, Biome, Vitest, and TypeScript:
yarn install --frozen-lockfile
yarn lint
yarn typecheck
yarn test
yarn test:coverage
yarn build
yarn package:checkUse make check for every local quality gate, yarn package or make package for
the audited tarball under .artifacts/npm/, make release VERSION=2.0.1 CHANNEL=latest
to prepare the manifest and CHANGELOG locally, and
make release-ci VERSION=2.0.1 CHANNEL=latest WATCH=1 to dispatch the release workflow.
License
Apache-2.0, see LICENSE. Copyright 2026 FicSys.
Versions up to and including 2.0.0 were published under the MIT License and remain available under those terms.
