/** * Represents a stream reader for reading a file in chunks. */ import { InboxApi, StoreApi } from ".."; export declare const FILE_DEFAULT_CHUNK_SIZE = 1048576; export declare class StreamReader { private _handle; private _offset; private _api; private readonly chunkSize; hasDataToRead: boolean; /** * Creates an instance of StreamReader. * * @param {number} handle - The file handle. * @param {StoreApi} api {@link StoreApi `StoreApi`} instance */ constructor(handle: number, api: StoreApi | InboxApi, chunkSize?: number); static readFile(api: InboxApi | StoreApi, fileID: string, chunkSize?: number): Promise; /** * Reads the next chunk of the file. * * @returns {Promise} A promise that resolves to true if there are more chunks to read, or false if the end of the file is reached. */ [Symbol.asyncIterator](): AsyncGenerator, number], void, unknown>; readNextChunk(): Promise; getFileContent(): Promise; /** * Aborts the reading process and closes the file handle. * * @returns {Promise} A promise that resolves when the file handle is closed. */ abort(): Promise; /** * Closes the file handle. * * @returns {Promise} A promise that resolves when the file handle is closed and returns file ID. */ close(): Promise; } /** * Represents a file stream uploader for uploading a Browser FileHandle in chunks. */ interface FileContainerApi { writeToFile: (chunk: Uint8Array) => Promise; closeFile: () => Promise; } export declare class FileUploader { private readonly _size; private offset; private readonly _api; private _reader; /** * Creates an instance of FileUploader. * * @param {number} handle - The file handle. * @param {File} file - The data (file content) to upload. * @param {StoreApi} api {@link StoreApi `StoreApi`} instance */ constructor(file: File, api: FileContainerApi); static uploadStoreFile({ storeApi, storeId, file, privateMeta, publicMeta, }: { storeId: string; file: File; storeApi: StoreApi; publicMeta?: Uint8Array; privateMeta?: Uint8Array; }): Promise; static uploadInboxFile({ inboxApi, inboxHandle, preparedFileUpload, }: { inboxHandle: number; preparedFileUpload: { file: File; handle: number; }; inboxApi: InboxApi; }): Promise; static prepareInboxUpload({ inboxApi, file, privateMeta, publicMeta, }: { inboxApi: InboxApi; file: File; publicMeta?: Uint8Array; privateMeta?: Uint8Array; }): Promise<{ file: File; handle: number; }>; /** * Gets the progress of uploading the file as a percentage. * * @returns {number} The progress percentage. */ get progress(): number; /** * Sends the next chunk of the file data to the server. * * @returns {Promise} A promise that resolves to true if there are more chunks to send, or false if all data has been sent. */ sendNextChunk(): Promise; uploadFileContent(): Promise; /** * Aborts the uploading process, closes the file handle, and deletes the uploaded part of the file. * * @returns {Promise} A promise that resolves when the file handle is closed and the uploaded part is deleted. */ abort(): Promise; /** * Closes the file handle. * * @returns {Promise} A promise that resolves when the file handle is closed and returns file ID. */ close(): Promise; } /** * Downloads a file from the server. * * @param {StoreApi|InboxApi} api - The API instance used for file operations. * @param {string} fileId - The ID of the file to download. * @param {string} [targetFileName] - The target file name for saving the downloaded file. * @returns {Promise} A promise that resolves when the download is complete. */ export declare function downloadFile(api: StoreApi | InboxApi, fileId: string, targetFileName?: string): Promise; export {};