UNPKG

@asi-ngtools/lib

Version:

This project is a little components library, simple to use, which will help you to simplify your project.

51 lines (50 loc) 2.24 kB
import { Observable } from 'rxjs'; import { HttpClient } from '@angular/common/http'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; /** * Service de gestion de fichier */ export declare class AsiFileService { private http; private sanitizer; constructor(http: HttpClient, sanitizer: DomSanitizer); fileToBase64(file: File, sanitize?: boolean): Observable<string>; fileToBase64Url(file: File, sanitize?: boolean): Observable<string>; fileToBase64Data(file: File): Observable<string>; blobToBase64(blob: Blob, sanitize?: boolean): Observable<string>; blobToBase64Url(blob: Blob, sanitize?: boolean): Observable<string>; blobToBase64Data(blob: Blob): Observable<string>; private toBase64(data, sanitize?); private toBase64Url(data, sanitize?); private toBase64Data(data); /** * Download the blob file with the specified name * @param fileAsBlob the file to download as a Blob * @param fileName the name to give to the downloaded file */ private saveToFile(fileAsBlob, fileName); /** * Transform a Blob into a File adding a file name and a last modified date * @param response The blob response */ private getFileFromBlobResponse(response); getFileUrl(file: File): SafeResourceUrl; getFileAsText(fileUrl: string): Observable<string>; getFileAsBlob(fileUrl: string): Observable<File>; getFileAsBlobFromPostRequest(fileUrl: string, body: any): Observable<File>; /** * Download the file at the given url * @param fileUrl The url of the downloadable file * @param fileName [Optional] The new name of the downloaded file */ downloadFile(fileUrl: string, fileName?: string): Observable<File>; /** * Download the file at the given url from a POST request * @param fileUrl The url of the downloadable file * @param body the POST request body * @param fileName [Optional] The new name of the downloaded file */ downloadFileFromPostRequest(fileUrl: string, body: any, fileName?: string): Observable<File>; getBlobImage(fileUrl: string): Observable<Blob>; uploadFile(url: string, file: File, reportProgress?: boolean): Observable<any>; }