nestjs-ftp
TypeScript icon, indicating that this package has built-in type declarations

0.1.13 • Public • Published

A NESTJS MODULE FOR FTP

Installation

Installation

npm install nestjs-ftp

About nestjs-ftp

This is an FTP client for NestJs, it supports FTPS over TLS, Passive Mode over IPv6, has a Promise-based API, and offers methods to operate on whole directories built on top of basic-ftp

Quick Start

Nestjs-ftp is build using the NestJs Dynamic modules and Factory providers approach, to configure it import the FtpModule module and the forRootFtpAsync service.

For example, your AppModule should look like this :

import { Module } from '@nestjs/common';



@Module({
    imports: [
        FtpModule.forRootFtpAsync({
            useFactory : async ()=>{
                return {
                  host:"test.rebex.net",
                  password:"password",
                  port:21,
                  user:"demo",
                  secure:true
                }
            },
            inject: [ConfigService]
        })
  controllers: [AppController],
  providers: [AppService],
  

})
export class AppModule { }

Then just inject the service just like any local service

For Example:

import { Injectable } from '@nestjs/common';
import { FtpService } from 'nestjs-ftp';

@Injectable()
export class AppService {
    constructor(private readonly _ftpService: FtpService){}

    async uploadFile(): string {
        try {
            await this._ftpService.upload(source,destination)
        } catch (error) {
            throw new Error(error)
        }
    }
}

Author

ABDESSALEM LETAIEF

License

Licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i nestjs-ftp

Weekly Downloads

804

Version

0.1.13

License

MIT

Unpacked Size

278 kB

Total Files

25

Last publish

Collaborators

  • abdessalemletaief