import { FileDescriptor } from '../../models/common/fileDescriptor'; import { FileStorageCapabilities, FileStorageExternalStorage, FileStorageService } from '../../services/files/fileStorage.service'; import { Service } from '../../services/service'; export declare const FILE_SERVER_SVC = "FileServerService"; /** * Helper class to handle image URLs (to avoid memory issues) * @class LocalImage */ export declare class LocalImage { /** * Image url to be use. e.g. in src attribute. * @type {string} * @memberof LocalImage */ url: string; /** * {@link FileDescriptor} associated with this LocalImage * @type {FileDescriptor} * @memberof LocalImage */ fd: FileDescriptor; /** * Method to be called to release the URL object created when instanciating the class * @memberof LocalImage */ release(): void; /** * Creates an instance of LocalImage. * Note: Careful, a URL object is created so {@link release()} is to be called when object is no longer in use * @param {FileDescriptor} fd image file descriptor * @param {Blob} blob file blob * @memberof LocalImage */ constructor(fd: FileDescriptor, blob: Blob); } /** * File server constraints (maxChunkSize, maxFileSize) for user * @class FileServerCapabilities */ export interface FileServerCapabilities { /** * Threshold from which it's better for clients to follow a download strategy by chunk [octet] */ maxChunkSizeDownload: number; /** * Threshold from which it's better for clients to follow an upload strategy by chunk [octet] */ maxChunkSizeUpload: number; /** * Data related with the external fileserver used */ externalStorage?: FileStorageExternalStorage; } export interface IFileServerService { uploadAFileByChunk(fileDescriptor: FileDescriptor, file: File): Promise; uploadFile(fileDescriptor: FileDescriptor): Promise; } export declare class FileServerService extends Service implements IFileServerService { readonly ONE_KILOBYTE = 1024; readonly ONE_MEGABYTE: number; readonly ONE_GIGABYTE: number; readonly FILE_RANGE: number; readonly PARALLEL_REQUEST_NB = 10; private _started; get started(): boolean; set started(value: boolean); private serviceStatusSubject; private portalURL; private fileMessageHandlerRef; private fileDescriptorEventHandler; private thumbnailPromises; private thumbnailPreviewPromises; private cache; private authService; private xmppService; private logger; private fileStorageService; private errorHelperService; private centralizedService; private mainService; capabilities: FileServerCapabilities; static getInstance(): FileServerService; static build(): FileServerService; private constructor(); private waitTillStarted; start(): Promise; stop(): Promise; reconnect(): void; attachHandlers(): void; private removeHandlers; /** * Get a "public URL" for a given {@link FileDescriptor} (API request to {@link https://api.openrainbow.org/filestorage/#api-files_server_download-files_getFileTemporaryURL Rainbow File Storage portal - files server download - 2 - Get backend temporary URL}) * @param {FileDescriptor} fileDescriptor for which we want to retrieve a public URL * @returns {Promise} Resolves with the public url * @memberof FileServerService */ getFileDescriptorPublicUrl(fileDescriptor: FileDescriptor): Promise; /** * Method creates an URL for a given fileDescriptor * @param {FileDescriptor} fileDescriptor for which we retrieve the URL * @param {boolean} [thumbnail] whether it is the thumbnail that is requested * @param {boolean} [cacheEnabled] whether to use cache or not * @returns {Promise} resolves with the URL * @memberof FileServerService */ getFileDescriptorUrl(fileDescriptor: FileDescriptor, thumbnail?: boolean, cacheEnabled?: boolean): Promise; /** * Removes a given {@link FileDescriptor} from cache * @param {FileDescriptor} fileDescriptor to be removed from cache * @memberof FileServerService */ removeFileDescriptorFromCache(fileDescriptor: FileDescriptor): void; /** * Clears the RainbowImageCache * @memberof FileServerService */ clearCache(): Promise; /** * Method retrieve the {@link LocalImage} of a given file * @param {string} fileDescriptorId ID of file * @param {boolean} thumbnail whether we want to retrieve the thumbnail * @param {boolean} [forced] whether we want to force a server request * @returns {Promise} resolves with the {@link LocalImage} * @memberof FileServerService */ getLocalImage(fileDescriptorId: string, thumbnail: boolean, forced?: boolean): Promise; private getLargeBlobThumbnail; /** * Method used to get partial data from server * @param {FileDescriptor} fileDescriptor of file to retrieve * @param {string} url to use for download * @param {number} minRange minRange for download operation * @param {number} maxRange maxRange for download operation * @param {number} index of partial request * @param {boolean} __cancelable cancellable request ? * @param {number} currentLoadingRef some kind of graphical stuff * @returns {Promise<{}>} resolves when partial data's download is complete * @memberof FileServerService */ private getPartialDataFromServer; getFileStorageService(): FileStorageService; /** * Retrieve Blob of thumbnail preview of a given file descriptor * @param {FileDescriptor} fileDescriptor for which we retrieve the blob * @returns {Promise} resolves with the blob * @memberof FileServerService */ private getBlobThumbnailPreviewFromFileDescriptor; /** * Retrieve Blob of thumbnail of a given file descriptor * @param {FileDescriptor} fileDescriptor for which we retrieve the blob * @returns {Promise} resolves with the blob * @memberof FileServerService */ getBlobThumbnailFromFileDescriptor(fileDescriptor: FileDescriptor): Promise; /** * Helper method to call getPartialDataFromServer and handle its response * @private * @param {FileDescriptor} fileDescriptor of file to retrieve * @param {string} url to use for download * @param {number} minRange minRange for download operation * @param {number} maxRange maxRange for download operation * @param {number} index of partial request * @param {boolean} cancelable cancellable request ? * @param {number} currentLoadingRef some kind of graphical stuff * @param {any[]} blobArray to fill with response * @param {Function} [actionOnPartialResponse] what to do when partial response is received * @returns {*} {Promise} * @memberof FileServerService */ private callAndProcessGetPartialDataFromServer; /** * Method retrieve the blob of a given file descriptor * @param {FileDescriptor} fileDescriptor whose blob we want to retrieve * @param {boolean} [cancelable] whether action is ancellable * @param {Function} [actionOnPartialResponse] what to do when partial response is received * @returns {Promise} resolves with the retieved blob * @memberof FileServerService */ getBlobFromFileDescriptor(fileDescriptor: FileDescriptor, cancelable?: boolean, actionOnPartialResponse?: Function): Promise; /** * Write the given blob's ArrayBuffer to fileDescriptor * @param {FileDescriptor} fd to fill * @param {ArrayBuffer[]} blobArray of data to write * @returns {void} * @memberof FileServerService */ private writeAvailableChunksInDisk; /** * Method creates blob from a file retrieved from server * @param {string} url server url for request * @param {FileDescriptor} fileDescriptor for which we retrieve the blob * @returns {Promise} resolves with the Blob created from data received from server * @memberof FileServerService */ getBlobFileDescriptorFromUrl(url: string, fileDescriptor: FileDescriptor): Promise; /** * Method retrieves an URL object from an url * @param {string} id [required] the ID of the image file * @returns {Promise} Object containing the orientation and the Object URL * @memberof FileServerService */ getBlobUrlAndOrientationByFileDescriptorId(id: string): Promise; /** * Method to read EXIF data for image to extract the orientation and store it * @param {FileDescriptor} fileDescriptor of image to read * @param {Blob} blob of file to analyze * @returns {Promise} : return the orientation value if available */ setImageOrientationForFileDescriptor(fileDescriptor: FileDescriptor, blob: Blob): Promise; /** * Method sends data to server using range request mecanism (RFC7233) * Note: this implementation uses fetch api. Thus, upload progress is not available. * @param {UploadRequestData} uploadRequestData to be sent * @returns {Promise<{}>} file descriptor data received as response from server or http error response * @memberof FileServerService */ private sendPartialDataToServer; /** * Method to upload a file by chunk * @param {FileDescriptor} fileDescriptor of file to upoad * @param {File} file to upload * @returns {Promise} resolves with the fileDescriptor uploaded * @memberof FileServerService */ uploadAFileByChunk(fileDescriptor: FileDescriptor, file: File): Promise; /** * Method to upload a file * @param {FileDescriptor} fileDescriptor of file to upload . Note: attribute "fileToSend" of fileDescriptor will be uploaded * @returns {Promise} resolves with the fileDescriptor uploaded * @memberof FileServerService */ uploadFile(fileDescriptor: FileDescriptor): Promise; /** * Method cancels the transfer for a given fileDescriptor * @param {string} fileDescriptorId ID of fileDescriptor transfer to cancel * @memberof FileServerService */ cancelCurrentFiletransfer(fileDescriptorId: string): void; /** * This API advice client about file server constraints (maxChunkSize, maxFileSize). (API request to {@link https://api.openrainbow.org/filestorage/#api-files_server_capabilities Rainbow File Storage portal - files server capabilities - Capabilities}) * @description * Method retrieves user quota (capabilities) for user * @returns {Promise} resolves with a {@link FileServerCapabilities} object * @memberof FileServerService */ getServerCapabilities(): Promise; getFileDescriptorCapability(fileDescriptor: FileDescriptor, capability: FileStorageCapabilities): boolean; } //# sourceMappingURL=fileServer.service.d.ts.map