UNPKG

@ngx-file-upload/core

Version:

Angular 19 file upload core package for async file uploads in angular containing validation, upload queue and async uploading.

121 lines (120 loc) 3.52 kB
import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { INgxFileUploadRequest, INgxFileUploadRequestData, NgxFileUploadOptions, NgxFileUploadState, type BeforeStartFn } from '../../api'; import type { NgxFileUploadFile } from './upload.file'; import { NgxFileUploadForm } from './upload.form'; export declare class NgxFileUploadRequest implements INgxFileUploadRequest { private http; private cancel$; private change$; private destroyed$; private totalSize; private options; private model; private readonly uploadForm; private hooks; private headers; private uploadUrl; get change(): Observable<INgxFileUploadRequestData>; get destroyed(): Observable<boolean>; get data(): INgxFileUploadRequestData; set state(state: NgxFileUploadState); get state(): NgxFileUploadState; get form(): NgxFileUploadForm; set url(url: string); get url(): string; requestId: string; constructor(http: HttpClient, files: NgxFileUploadFile | NgxFileUploadFile[], options: NgxFileUploadOptions); getHeader(name: string): string | import("../../api").AuthorizationHeader | undefined; /** * @description add additional headers to request */ addHeader(name: string, value: string): void; /** * @description remove additional headers from request */ removeHeader(name: string): void; beforeStart(hook: BeforeStartFn): void; /** * cancel current file upload, this will complete change subject */ cancel(): void; destroy(): void; /** * return true if upload was not completed since the server * sends back an error response */ hasError(): boolean; isCompleted(ignoreError?: boolean): boolean; isCanceled(): boolean; isInvalid(): boolean; isProgress(): boolean; isPending(): boolean; isIdle(): boolean; isRequestCompleted(): boolean; /** * restart download again * reset state, and reset errors */ retry(): void; /** * start file upload */ start(): void; /** * @description internal use only, before start hooks can become async if they return simple * boolean value or a promise. A boolean Value will turned into a Promise into an observable. */ run(): void; removeInvalidFiles(): void; /** * @description updates validility for upload request */ private updateValidility; /** * call hooks in order, see playground * @see https://rxviz.com/v/58GkkYv8 */ private get beforeStartHook$(); private createForm; /** * build form data and send request to server */ private startUploadRequest; /** * create upload body which will should be send */ private createUploadBody; /** * create upload request headers */ private createUploadHeaders; /** * create authorization header which will send */ private createAuthroizationHeader; /** * request responds with an error */ private handleError; /** * handle all http events */ private handleHttpEvent; /** * handle http progress event */ private handleProgress; /** * upload completed with an success */ private handleResponse; /** * send notification to observers */ private notifyObservers; /** * upload has been completed, canceled or destroyed */ private finalizeUpload; }