UNPKG

filestack-js

Version:

Official JavaScript library for Filestack

112 lines (111 loc) 2.6 kB
import { EventEmitter } from 'eventemitter3'; import { Session, Security } from '../../client'; import { UploadOptions, StoreUploadOptions } from '../upload/types'; import { InputFile } from './file_tools'; import { UploadTags } from './file'; export interface ProgressEvent { totalPercent: number; totalBytes: number; files?: { (key: string): ProgressEvent; }; } /** * Uploader main class for now its supporting only s3 upload type * * @export * @class Upload */ export declare class Upload extends EventEmitter { private readonly options; private storeOptions; /** * Uploader instance * * @private * @type {S3Uploader} * @memberof Upload */ private uploader; /** * Should we overwrite file name * * @private * @memberof Upload */ private overrideFileName; private lastProgress; private progressIntervalHandler; private sanitizerOptions; constructor(options?: UploadOptions, storeOptions?: StoreUploadOptions); /** * Set session object to uploader * * @deprecated * @param {Session} session * @memberof Upload */ setSession(session: Session): void; /** * Set cancel token to controll upload flow * * @param {*} token * @returns * @memberof Upload */ setToken(token: any): any; /** * Sets security to uploader instance * * @param {Security} security * @memberof Upload */ setSecurity(security: Security): void; /** * Set upload tags * * @param {Tags} tags * @memberof Upload */ setUploadTags(tags: UploadTags): void; /** * Upload single file * * @param {(InputFile)} file * @param {(string)} altText * @returns {Promise<any>} * @memberof Upload */ upload(input: InputFile, altText?: string): Promise<any>; /** * Upload multiple files at once * * @param {(InputFile[])} input * @returns {Promise<any>} * @memberof Upload */ multiupload(input: InputFile[]): Promise<any>; /** * RUn progress with userdefined interval * * @private * @returns * @memberof Upload */ private startProgressInterval; /** * Stop progress interval after upload * * @private * @memberof Upload */ private stopProgressInterval; /** * Handle upload interval and normalize values * * @private * @param {ProgressEvent} progress * @memberof Upload */ private handleProgress; }