UNPKG

@leancodepl/utils

Version:

Common utility functions and React hooks for web applications

30 lines (29 loc) 971 B
type DownloadFileOptions = { name?: string; }; /** * Downloads a file from a URL by creating a temporary download link. * * @param url - The URL to download from * @param options - Optional download options including filename * @example * ```typescript * // Download from URL * downloadFile('https://example.com/file.pdf', { name: 'document.pdf' }); * ``` */ export declare function downloadFile(url: string, options?: DownloadFileOptions): void; /** * Downloads a file from a Blob or MediaSource object by creating a temporary object URL. * * @param obj - The Blob or MediaSource object to download * @param options - Optional download options including filename * @example * ```typescript * // Download from Blob * const blob = new Blob(['Hello World'], { type: 'text/plain' }); * downloadFile(blob, { name: 'hello.txt' }); * ``` */ export declare function downloadFile(obj: Blob | MediaSource, options?: DownloadFileOptions): void; export {};