UNPKG

@cumulus/ingest

Version:
70 lines 2.58 kB
import JSFtp, { ListError } from 'jsftp'; import { FtpProviderClientListItem, ProviderClient, ProviderClientListItem } from './types'; interface FtpProviderClientConstructorParams { host: string; port?: number; useList?: boolean; username?: string; password?: string; encrypted?: boolean; } declare class FtpProviderClient implements ProviderClient { private readonly providerConfig; private readonly host; private ftpClient?; private plaintextUsername?; private plaintextPassword?; constructor(providerConfig: FtpProviderClientConstructorParams); getUsername(): Promise<string>; getPassword(): Promise<string>; buildFtpClient(): Promise<JSFtp>; errorHandler(rejectFn: (reason?: any) => void, error: Error | ListError): void; /** * Download a remote file to disk * * @param {Object} params - parameter object * @param {string} params.remotePath - the full path to the remote file to be fetched * @param {string} params.localPath - the full local destination file path * @returns {Promise.<string>} - the path that the file was saved to */ download(params: { remotePath: string; localPath: string; }): Promise<string>; /** * List all files from a given endpoint * @param {string} path - path to list * @param {number} counter - recursive attempt counter * @returns {Promise} promise of contents * @private */ _list(path: string, counter?: number): Promise<FtpProviderClientListItem[]>; /** * List all files from a given endpoint * @param {string} path - path to list * @returns {Promise} */ list(path: string): Promise<ProviderClientListItem[]>; /** * Download the remote file to a given s3 location * * @param {Object} params - function parameters * @param {string} params.remotePath - the full path to the remote file to be fetched * @param {string} params.bucket - destination s3 bucket of the file * @param {string} params.key - destination s3 key of the file * @returns {Promise.<{ s3uri: string, etag: string }>} an object containing * the S3 URI and ETag of the destination file */ sync(params: { fileRemotePath: string; destinationBucket: string; destinationKey: string; }): Promise<{ s3uri: string; etag?: string; }>; connect(): Promise<void>; end(): Promise<void>; } export = FtpProviderClient; //# sourceMappingURL=FtpProviderClient.d.ts.map