0.1.13 • Published 3 years ago

nestjs-ftp v0.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.