UNPKG

@glr/ngx-file-uploader

Version:
99 lines (98 loc) 2.52 kB
import { EventEmitter } from '@angular/core'; import { FileManager } from './fileManager.core'; /** * Absractr proctol class if someone want to write his own protocol * * @export * @abstract * @class Protocol */ export declare abstract class Protocol { _progress: EventEmitter<any>; _load: EventEmitter<any>; _error: EventEmitter<any>; _abort: EventEmitter<any>; connection: any; private _id; private _connections; /** * Creates an instance of Protocol and for each protocol an own unique ID. * * * @memberOf Protocol */ constructor(); /** * Call uploader method _onCompleteFile. * * @param {FileManager} _file * @param {any} response * @param {any} status * @param {any} headers * * @memberOf Protocol */ _onLoad(_file: FileManager, response: any, status: number, headers: any): void; /** * Call uploader methodes _onErrorFile and _onCompleteFile. * * @param {FileManager} _file * @param {any} response * @param {any} status * @param {any} headers * * @memberOf Protocol */ _onError(_file: FileManager, response: any, status: number, headers: any): void; /** * Call uploader methodes _onErrorFile and _onCompleteFile. * * @param {FileManager} _file * @param {any} response * @param {any} status * @param {any} headers * * @memberOf Protocol */ _onAbort(_file: FileManager, response: any, status: number, headers: any): void; /** * Validate response status code. * * @param {number} status * @returns {boolean} * * @memberOf Protocol */ _isSuccessCode(status: number): boolean; isConnected(_file: FileManager): any; removeConnection(_file: FileManager): void; /** * Must be implemented at each protocol class. * * @abstract * @param {FileManager} _file * * @memberOf Protocol */ abstract run(_file: FileManager): any; abstract cancel(_file: FileManager): void; } /** * Standard protocol for server communication (file uploading) * * @export * @class ProtocolXHR * @extends {Protocol} */ export declare class ProtocolXHR extends Protocol { constructor(); /** * Implementation of the abstract.protocol method `run` * * @param {FileManager} _file * * @memberOf ProtocolXHR */ run(_file: FileManager): void; cancel(_file: FileManager): void; }