nestjs-ftp
Advanced tools
Comparing version 0.1.10 to 0.1.11
/// <reference types="node" /> | ||
import { IConnectionOptions } from './interfaces/ftp.interface'; | ||
import { FileInfo, FTPResponse, UploadOptions } from 'basic-ftp'; | ||
import { Readable, Writable } from "stream"; | ||
import { Readable, Writable } from 'stream'; | ||
import { IConnectionOptions } from './interfaces/connection-options.interface'; | ||
export declare class FtpService { | ||
@@ -12,2 +12,4 @@ private _options; | ||
upload(source: Readable | string, toRemotePath: string, options?: UploadOptions): Promise<FTPResponse>; | ||
delete(fileRemotePath: string): Promise<FTPResponse>; | ||
size(fileRemotePath: string): Promise<number>; | ||
} |
@@ -24,3 +24,2 @@ "use strict"; | ||
this._ftpClient = new basic_ftp_1.Client(); | ||
this._ftpClient.ftp.verbose = true; | ||
} | ||
@@ -57,2 +56,22 @@ async list(path) { | ||
} | ||
async delete(fileRemotePath) { | ||
try { | ||
await this._ftpClient.access(this._options); | ||
return await this._ftpClient.remove(fileRemotePath); | ||
} | ||
catch (err) { | ||
common_1.Logger.log(err); | ||
} | ||
this._ftpClient.close(); | ||
} | ||
async size(fileRemotePath) { | ||
try { | ||
await this._ftpClient.access(this._options); | ||
return await this._ftpClient.size(fileRemotePath); | ||
} | ||
catch (err) { | ||
common_1.Logger.log(err); | ||
} | ||
this._ftpClient.close(); | ||
} | ||
}; | ||
@@ -59,0 +78,0 @@ FtpService = __decorate([ |
@@ -1,15 +0,6 @@ | ||
/// <reference types="node" /> | ||
import { ModuleMetadata } from "@nestjs/common/interfaces"; | ||
import { ConnectionOptions as TLSConnectionOptions } from "tls"; | ||
import { IConnectionOptions } from "./connection-options.interface"; | ||
export interface IFtpConnectionOptions extends Pick<ModuleMetadata, 'imports'> { | ||
useFactory: (...args: any[]) => Promise<IConnectionOptions>; | ||
useFactory: (...args: any[]) => Promise<IConnectionOptions> | IConnectionOptions; | ||
inject?: any[]; | ||
} | ||
export interface IConnectionOptions { | ||
readonly host?: string; | ||
readonly port?: number; | ||
readonly user?: string; | ||
readonly password?: string; | ||
readonly secure?: boolean | "implicit"; | ||
readonly secureOptions?: TLSConnectionOptions; | ||
} |
{ | ||
"name": "nestjs-ftp", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Nestjs-ftp is a NestJs Module repository of basic-ftp package", | ||
@@ -5,0 +5,0 @@ "author": "Abdessalem Letaief", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
277773
25
191