import { HttpContext, HttpHeaders, HttpParams, HttpResponse } from "@angular/common/http"; import { Observable } from "rxjs"; import * as i0 from "@angular/core"; type FileDownloadResponseType = 'blob' | 'text' | 'arraybuffer'; type FileDownloadHeadersType = HttpHeaders | Record; type FileDownloadParamsType = HttpParams | Record; interface IFileSaveOptions { /** Caller-owned native save anchor without a click handler; its attributes are restored after saving. */ link: HTMLAnchorElement; /** Original user event whose default action is prevented synchronously before saving or requesting content. */ event?: Event; /** Explicit download filename, overriding the response Content-Disposition filename. */ filename?: string; /** Filename used when no explicit or response filename is available; defaults to 'download'. */ fallbackFilename?: string; /** Optional MIME label for the original bytes; this does not convert the file format. */ mimeType?: string; } interface IFileDownloadOptions extends IFileSaveOptions { /** URL response format; defaults to 'blob'. Caller-supplied Observable responses retain their own format. */ responseType?: FileDownloadResponseType; headers?: FileDownloadHeadersType; params?: FileDownloadParamsType; context?: HttpContext; withCredentials?: boolean; } type FileDownloadSourceType = string | Observable>; export declare class FileService { private readonly http; /** * Creates a GET request with the caller's response format and HTTP settings. * @param url - Backend URL from which to retrieve file content. * @param options - Headers, query parameters, context, credentials and response format. * @returns A cold Observable that requests the full HTTP response on subscription. */ private getResponse; /** * Wraps file content in a Blob, optionally relabelling its MIME type without converting the file format. * @param content - Existing Blob, text or binary content to save. * @param mimeType - Optional MIME label to apply to the content. * @returns The existing Blob when its MIME label is unchanged, otherwise a Blob containing the same content. */ createBlob(content: BlobPart, mimeType?: string): Blob; /** * Prevents the supplied event's default action and starts a native download through the caller-owned anchor. * @param content - Blob, text or binary content to download. * @param options - Save anchor, optional event, filename preferences and optional MIME label. */ saveFile(content: BlobPart, options: IFileSaveOptions): void; /** * Saves response content using filename and MIME preferences resolved from the options, Blob and headers. * @param response - HTTP response containing the file content and any download headers. * @param options - Caller-owned anchor, optional event and overrides for the download. * @throws Error when the response has no body; empty content remains a valid file. */ saveResponse(response: HttpResponse, options: IFileSaveOptions): void; /** * Downloads a URL or supplied response Observable, preventing the event's default action immediately. * @param source - Backend URL or response Observable supplied for any HTTP method. * @param options - Save settings and HTTP options; request settings apply only to URL sources. * @returns An Observable that saves received responses and forwards errors; the caller controls cancellation. */ downloadFile(source: FileDownloadSourceType, options: IFileDownloadOptions): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export type { FileDownloadHeadersType, FileDownloadParamsType, FileDownloadResponseType, FileDownloadSourceType, IFileDownloadOptions, IFileSaveOptions };