import { CreateRequestOptions } from "../Data"; import { RequestFactory } from "../Requests/RequestFactory"; import { TypeOptions } from "../Sitefinity"; import { ChunkFileResult } from "./chunked-file-upload.utilities"; /** * @description Entry point for all chunk upload related tasks * @export * @class ChunkUploadSdk */ export declare class ChunkUploadSdk { private urlOptions; private factory; constructor(urlOptions: TypeOptions, factory: RequestFactory); /** * @description Gets the needed information to start uploading chunks to the server * @param {GetChunkUploadInfoRequestOptions} parameters * @memberof ChunkUploadSdk */ getChunkUploadInfo(parameters: GetChunkUploadInfoRequestOptions): void; /** * @description Sends a single chunk request to the server * @param {UploadChunkRequestOptions} parameters * @memberof ChunkUploadSdk */ uploadChunk(parameters: UploadChunkRequestOptions): void; /** * @description Sends the commit chunks request to the server * @param {CommitChunksRequestOptions} parameters * @memberof ChunkUploadSdk */ commitChunks(parameters: CommitChunksRequestOptions): void; /** * @description This request is intended to be used when something in the chunk upload process fails to delete the sent chunks * @param {CleanUpChunksRequestOptions} parameters * @memberof ChunkUploadSdk */ cleanUpChunks(parameters: CleanUpChunksRequestOptions): void; /** * Chunks the provided file. If the file is a base64 string this method will convert it to a blob and then chunk it. * * @param {(Blob | string)} file * @param {number} chunkSize * @param {string} contentTypeMime * @return {*} {ChunkFileResult} * @memberof ChunkUploadService */ chunkFile(file: Blob | string, chunkSize: number, contentTypeMime: string): ChunkFileResult; } /** * @description This interface shows the minimum data needed to create a single chunk upload request * @export * @interface UploadChunkRequestOptions * @extends {CreateRequestOptions} */ export interface UploadChunkRequestOptions extends CreateRequestOptions { /** * @description the data needed to construct the request * @type {{ * fileMimeType: string; * chunkedFileUploadSessionId: string; * chunkSize: number; * chunkOrdinal: number; * numberOfChunks: number; * positionOfChunkInQueue?: number; * chunkBlob: Blob; * blobStorageProviderName: string; * }} * @memberof UploadChunkRequestOptions */ data: { /** * @description the file's mime type * @type {string} */ fileMimeType: string; /** * @description the file's name * @type {string} */ fileName: string; /** * @description the current chunk upload session Id * @type {string} */ chunkedFileUploadSessionId: string; /** * @description the chunk size in bytes * @type {number} */ chunkSize: number; /** * @description the chunk's ordinal * @type {number} */ chunkOrdinal: number; /** * @description the total number of chunks * @type {number} */ numberOfChunks: number; /** * @description Optional. The position of the chunk in the request queue, this property is used to calculate the progress of the upload * @type {number} */ positionOfChunkInQueue?: number; /** * @description The chunk data * @type {Blob} */ chunkBlob: Blob; /** * @description the target blob storage provider's name * @type {string} */ blobStorageProviderName: string; }; } /** * @description This interface shows the minimum data needed to create a commit chunks request * @export * @interface CommitChunksRequestOptions * @extends {CreateRequestOptions} */ export interface CommitChunksRequestOptions extends CreateRequestOptions { /** * @description the data needed to construct the request * @type {{ * chunkedFileUploadSessionId: string; * contentType: string; * fileTotalSize: number; * numberOfChunks: number; * name: string; * blobStorageProviderName: string; * uploadProperties: { [key: string]: string }; * itemId?: string; * }} * @memberof CommitChunksRequestOptions */ data: { /** * @description the current chunk upload session Id * @type {string} */ chunkedFileUploadSessionId: string; /** * @description the file's mime type * @type {string} */ contentType: string; /** * @description the total size of the file * @type {number} */ fileTotalSize: number; /** * @description the total number of chunks * @type {number} */ numberOfChunks: number; /** * @description the file's name * @type {string} */ name: string; /** * @description the target blob storage provider's name * @type {string} */ blobStorageProviderName: string; /** * @description the properties of the uploaded file like the Title, UrlName, etc * @type {{ [key: string]: string }} */ uploadProperties: { [key: string]: string; }; /** * @description Optional. Used when updating a media item, can be null when used to create a new media file. * @type {string} */ itemId?: string; }; } /** * @description This interface shows the minimum data needed to create request to get the chunk upload information for the current library from the server * @export * @interface GetChunkUploadInfoRequestOptions * @extends {CreateRequestOptions} */ export interface GetChunkUploadInfoRequestOptions extends CreateRequestOptions { /** * @description the data needed to construct the request * @type {{ * libraryId: string; * }} * @memberof GetChunkUploadInfoRequestOptions */ data: { /** * @description the parent library (not folder) in which the file will be uploaded to * @type {string} */ libraryId: string; }; } /** * @description This interface show the minimum data needed to create a request to delete all chunk from a chunk upload session * @export * @interface CleanUpChunksRequestOptions * @extends {CreateRequestOptions} */ export interface CleanUpChunksRequestOptions extends CreateRequestOptions { /** * @description the data needed to construct the request * @type {{ * chunkedFileUploadSessionId: string; * blobStorageProviderName: string; * }} * @memberof CleanUpChunksRequestOptions */ data: { /** * @description the current chunk upload session Id * @type {string} */ chunkedFileUploadSessionId: string; /** * @description the target blob storage provider's name * @type {string} */ blobStorageProviderName: string; }; } /** * @description This is a data transfer object that shows the information provided by the getChunkUploadInfo request * @export * @interface ChunkUploadInfoDTO */ export interface ChunkUploadInfoDTO { /** * @description shows wether the current blob storage provider supports uploading in chunks * @type {boolean} * @memberof ChunkUploadInfoDTO */ ProviderSupportsChunkUpload: boolean; /** * @description the target blob storage provider's name * @type {string} * @memberof ChunkUploadInfoDTO */ BlobStorageProviderName: string; /** * @description the current chunk upload session Id * @type {string} * @memberof ChunkUploadInfoDTO */ ChunkedFileUploadSessionId: string; /** * @description the chunk size in bytes * @type {number} * @memberof ChunkUploadInfoDTO */ ChunkSize: number; /** * @description the maximum amount of time a chunk should be retired * @type {number} * @memberof ChunkUploadInfoDTO */ MaxRetryCountForChunk: number; /** * @description the maximum simultaneous requests that should be sent to the server * @type {number} * @memberof ChunkUploadInfoDTO */ MaxSimultaneousChunkUploadRequestsPerSession: number; } /** * @description A DTO containing the data that the server responds with when a chunk is uploaded * @export * @interface ChunkUploadResult */ export interface ChunkUploadResult { /** * @description indicates whether the chunk has been successfully uploaded * @type {boolean} * @memberof ChunkUploadResult */ SuccessfullyUploaded: boolean; /** * @description the current chunk upload session Id * @type {string} * @memberof ChunkUploadResult */ ChunkedFileUploadSessionId: string; }