file-handler.ts 796 Bytes
import { File } from './file';

export interface FileHandler {

    /**
     * The donwload works as following:
     *  - if the file already exists and is not empty: trigger complete
     *  - if the download is in progress: trigger next (0-1 progress for percent of download)
     *  - if the download enters any error condition, trigger error and an already downloaded part of the file
     */
    download(source:string, target:string) : FileHandler;

    /**
     * Remove all files, which are not inside the files array from local storage
     */
    cleanup(files: Array<File>, basePath?: string);

    on(event:string, handler:(...params: any[]) => void) : FileHandler;

    once(event:string, handler:(...params: any[]) => void) : FileHandler;

    removeAllListeners() : FileHandler;

}