// Type definitions for FineUploader 5.x.x // Project: http://fineuploader.com/ // Definitions by: Sukhdeep Singh /** * **The FineUploader namespace contains all the methods, options, events and types** * * ###Example Usage: * declaring core options: * ```typescript * let coreOptions: FineUploader.CoreOptions; * ``` * then do something as: * ```typescript * coreOptions.autoUpload = false; * ``` */ declare namespace FineUploader { /* ========================================================== CORE & UI ===================================================================== */ /** * type for `resizeInfo` object */ interface ResizeInfo { /** * **The original `File` or `Blob` object, if available.** */ blob?: File | Blob; /** * **Desired height of the image after the resize operation.** */ height?: number; /** * **The original HTMLImageElement object, if available.** */ image?: HTMLImageElement; /** * **`HTMLCanvasElement` element containing the original image data (not resized).** */ sourceCanvas?: HTMLCanvasElement; /** * **`HTMLCanvasElement` element containing the `HTMLCanvasElement` that should contain the resized image.** */ targetCanvas?: HTMLCanvasElement; /** * **Desired width of the image after the resize operation.** */ width?: number; } /** * Callback type for `customResizer` parameter */ interface CustomResizerCallBack { /** * **Contribute this function to manually resize images using alternate 3rd party libraries** * * @param ResizeInfo resizeInfo : the ResizeInfo object containing all the resize values/options * @returns Promise : Once the resize is complete, the function must return a promise */ (resizeInfo: ResizeInfo): Promise; } /** * A BlobWrapper object type */ interface BlobWrapper { /** * **the bytes of the `Blob` object being uploaded** */ blob: Blob; /** * **the name of the `Blob`** */ name: string; } /** * A CanvasWrapper Object type */ interface CanvasWrapper { /** * **the `` to be converted to a file & then uploaded** */ canvas: HTMLCanvasElement; /** * **the name to assign to the created file** */ name: string; /** * **`1`-`100` value indicating the desired quality of the converted file (only for `image/jpeg`)** */ quality: number; /** * **MIME type of the file to create from this ``** */ type: MimeType; } /** * Resumable file object type */ interface ResumableFileObject { /** * **filename** */ name: string; /** * **the unique id** */ uuid: number; /** * **the index of the part where the resume will start from** */ partIdx: number; } /** * Resumable file object type for S3 */ interface S3ResumableFileObject extends ResumableFileObject { /** * **The associated object's S3 key** */ key: string; } /** * Resumable file object type for Azure */ interface AzureResumableFileObject extends ResumableFileObject { /** * **The associated file's blob name in Azure Blob Storage** */ key: string; } /** * type for getUploads method's filter parameter */ interface UploadFilter { /** * **the id of the file** */ id: number | number[]; /** * **the uuid of the file** */ uuid: number | number[]; /** * **status of the file** */ status: string | string[]; } /** * type for getUploads method's return object */ interface FoundUploadItems extends UploadFilter { /** * **the name of the file** */ name: string; /** * **the size of the file** */ size: string; } /** * ScaleImageOptions */ interface ScaleImageOptions { /** * required */ maxSize: number; /** * @default `true` */ orient?: boolean; /** * **defaults to the type of the reference image** */ type?: string; /** * **number between `0` and `100`** * * @default `80` */ quality?: number; /** * @default `false` */ includeExif?: boolean; /** * **Ignored if the current browser does not support image previews.** * * If you want to use an alternate library to resize the image, you must contribute a function for this option that returns a `Promise`. * * Once the resize is complete, your promise must be fulfilled. * You may, of course, reject your returned `Promise` is the resize fails in some way. */ customResizer?: CustomResizerCallBack; } /** * formatFileName function type */ interface FormatFileNameFuncton { (fileOrBlobName): String; } /** * BlobsOptions */ interface BlobsOptions { /** * **The default name to be used for nameless `Blob`s** * * @default `Misc data` */ defaultName?: string; } /** * CameraOptions */ interface CameraOptions { /** * **`null` allows camera access on the default button in iOS.** * * Otherwise provide an extra button container element to target * * @default `null` */ button?: HTMLElement; /** * **Enable or disable camera access on iOS (iPod, iPhone, and iPad) devices.** * * ###Note: * Enabling this will disable multiple file selection * * @default `false` */ ios?: boolean; } /** * ConcurrentOptions */ interface ConcurrentOptions { /** * **Allow multiple chunks to be uploaded simultaneously per file** * * @default `false` */ enabled?: boolean; } /** * ChunkingOptions */ interface ChunkingOptions { /** * concurrent Chunking options */ concurrent?: ConcurrentOptions; /** * **Enable or disable splitting the file separate chunks. Each chunks is sent in a separate request** * * @default `false` */ enabled?: boolean; /** * **Ensure every file is uploaded in chunks, even if the file can only be split up into 1 chunk.** * * Does not apply if chunking is not possible in the current browser * * @default `false` */ mandatory?: boolean; /** * **The maximum size of each chunk, in bytes** * * @default `2000000` */ partSize?: number; /** * **ParamNamesOptions** */ paramNames?: ParamNamesOptions; /** * **SuccessOptions** */ success?: SuccessOptions; } /** * ParamNamesOptions */ interface ParamNamesOptions { /** * **Name of the parameter passed with a chunked request that specifies the size in bytes of the associated chunk** * * @default `'qqchunksize'` */ chunkSize?: string; /** * **Name of the parameter passed with a chunked request that specifies the starting byte of the associated chunk** * * @default `'qqpartbyteoffset'` */ partByteOffset?: string; /** * **Name of the parameter passed with a chunked request that specifies the index of the associated partition** * * @default `'qqpartindex'` */ partIndex?: string; /** * **Name of the parameter passed with a chunked request that specifies the total number of chunks associated with the `File` or `Blob`** * * @default `'qqtotalparts'` */ totalParts?: string; /** * **Sent with the first request of the resume with a value of `true`** * * @default `'qqresume'` */ resuming?: string; /** * **totalFileSize** * * @default `'qqtotalfilesize'` */ totalFileSize?: string; } /** * SuccessOptions */ interface SuccessOptions { /** * **Endpoint to send a POST after all chunks have been successfully uploaded for each file.** * * Required if the `concurrent.enabled` option is set * * @default `null` */ endpoint?: string; } /** * CorsOptions */ interface CorsOptions { /** * **Enable or disable cross-origin requests from IE9 and older where XDomainRequest must be used** * * @default `false` */ allowXdr?: boolean; /** * **Enable or disable cross-domain requests** * * @default `false` */ expected?: boolean; /** * **Enable or disable sending credentials along with each cross-domain request. Ignored if allowXdr is true and IE9 is being used** * * @default `false` */ sendCredentials?: boolean; } /** * DeleteFileOptions */ interface DeleteFileOptions { /** * **Any additional headers to attach to all delete file requests** * * @default `{}` */ customHeaders?: any; /** * **Enable or disable deletion of uploaded files** * * @default `false` */ enabled?: boolean; /** * **The endpoint to which delete file requests are sent.** * * @default `'/server/upload'` */ endpoint?: string; /** * **Set the method to use for delete requests.** * * Accepts `'POST'` or `'DELETE'` * * @default `'DELETE'` */ method?: string; /** * **Any additional parameters to attach to delete file requests** * * @default `{}` */ params?: any; } /** * ExtraButtonsOptions */ interface ExtraButtonsOptions { /** * **The container element for the upload button** * * @default `undefined` */ element: HTMLElement; /** * **This value will be used when creating the `title` attribute for the underlying ``.** * * If not provided, the `text.fileInputTitle` option will be used instead * * @default `'file input'` */ fileInputTitle?: string; /** * **`true` to allow folders to be selected, `false` to allow files to be selected.** * * @default `false` */ folders?: boolean; /** * **Specify to override the default `multiple` value** * * @default `true` */ multiple?: boolean; /** * **Specify to override the default `validation` option specified.** * * Any `validation` properties not specified will be inherited from the default `validation` option * * @default `validation` */ validation?: any; } /** * FormOptions */ interface FormOptions { /** * **This can be the ID of the
or a reference to the element** * * @default `'qq-form'` */ element: string | HTMLElement; /** * **If Fine Uploader is able to attach to a form, this value takes the place of the base `autoUpload` option** * * @default `false` */ autoUpload: boolean; /** * **Set this to `false` if you do not want Fine Uploader to intercept attempts to submit your form.** * * By default, Fine Uploader will intercept submit attempts and instead upload all submitted files, including data from your form in each upload request * * @default `true` */ interceptSubmit: boolean; } /** * Messages */ interface Messages { /** * **Text passed to the error event handler if a submitted item is zero bits** * * @default `'{file} is empty, please select files again without it.'` */ emptyError?: string; /** * **Text passed to the error event handler if an image is too tall** * * @default `'Image is too tall.'` */ maxHeightImageError?: string; /** * **Text passed to the error event handler if an image is too wide** * * @default `'Image is too wide.'` */ maxWidthImageError?: string; /** * **Text passed to the error event handler if an image is not tall enough** * * @default `'Image is not tall enough.'` */ minHeightImageError?: string; /** * **Text passed to the error event handler if an image is not wide enough** * * @default `'Image is not wide enough.'` */ minWidthImageError?: string; /** * **Text passed to the error event handler if the item is too small** * * @default `'{file} is too small, minimum file size is {minSizeLimit}.'` */ minSizeError?: string; /** * **Text passed to the error event handler if any empty array of items is submitted** * * @default `'No files to upload.'` */ noFilesError?: string; /** * **Text displayed to the user when they attempt to leave the page while uploads are still in progress** * * @default `'The files are being uploaded, if you leave now the upload will be canceled.'` */ onLeave?: string; /** * **Text passed to the error event handler if a retry attempt is declared a failed due to a violation of the `validation.itemLimit` rule** * * @default `'Retry failed - you have reached your file limit.'` */ retryFailTooManyItemsError?: string; /** * **Text passed to the error event handler if a submitted item is too large.** * * @default `'{file} is too large, maximum file size is {sizeLimit}.'` */ sizeError?: string; /** * **Text passed to the error event handler if a submit is ignored due to a violation of the `validation.itemLimit` rules** * * @default `'Too many items ({netItems}) would be uploaded. Item limit is {itemLimit}.'` */ tooManyItemsError?: string; /** * **Text passed to the error event handler if an invalid file type is detected** * * @default `'{file} has an invalid extension. Valid extension(s): {extensions}.'` */ typeError?: string; /** * **Message displayed if the browser is iOS8 Safari and the corresponding workarounds option is not disabled** * * @default `'Unrecoverable error - this browser does not permit file uploading of any kind due to serious bugs in iOS8 Safari. Please use iOS8 Chrome until Apple fixes these issues.'` */ unsupportedBrowserIos8Safari?: string; } /** * PasteOptions */ interface PasteOptions { /** * **The default name given to pasted images** * * @default `'pasted_image'` */ defaultName?: string; /** * **Enable this feature by providing any HTMLElement here** * * @default `null` */ targetElement?: HTMLElement; } /** * ResumeOptions */ interface ResumeOptions { /** * The number of days before a persistent resume record will expire * * @default `7` */ recordsExpireIn?: number; /** * Enable or disable the ability to resume failed or stopped chunked uploads * * @default `false` */ enabled?: boolean; /** * paramNames.resuming - Sent with the first request of the resume with a value of `true`. * * @default `'qqresume'` */ paramNames?: ParamNamesOptions; } /** * RetryOptions */ interface RetryOptions { /** * The number of seconds to wait between auto retry attempts * * @default `5` */ autoAttemptDelay?: number; /** * Enable or disable retrying uploads that receive any error response * * @default `false` */ enableAuto?: boolean; /** * The maximum number of times to attempt to retry a failed upload * * @default `3` */ maxAutoAttempts?: number; /** * This property will be looked for in the server response and, if found and `true`, will indicate that no more retries should be attempted for this item * * @default `'preventRetry'` */ preventRetryResponseProperty?: string; } /** * RequestOptions */ interface RequestOptions { /** * Additional headers sent along with each upload request */ customHeaders?: any; /** * The endpoint to send upload requests to * * @default `'/server/upload'` */ endpoint?: string; /** * The name of the parameter passed if the original filename has been edited or a `Blob` is being sent * * @default `'qqfilename'` */ filenameParam?: string; /** * Force all uploads to use multipart encoding * * @default `true` */ forceMultipart?: boolean; /** * The attribute of the input element which will contain the file name. * * For non-multipart-encoded upload requests, this will be included as a parameter in the query string of the URI with a value equal to the file name * * @default `'qqfile'` */ inputName?: string; /** * Specify a method to use when sending files to a traditional endpoint. This option is ignored in older browsers (such as IE 9 and older) * * @default `'POST'` */ method?: string; /** * The parameters that shall be sent with each upload request */ params?: any; /** * Enable or disable sending parameters in the request body. * * If `false`, parameters are sent in the URL. * Otherwise, parameters are sent in the request body * * @default `true` */ paramsInBody?: boolean; /** * The name of the parameter the uniquely identifies each associated item. The value is a Level 4 UUID * * @default `'qquuid'` */ uuidName?: string; /** * The name of the parameter passed that specifies the total file size in bytes * * @default `'qqtotalfilesize'` */ totalFileSizeName?: string; } /** * SizeOptions */ interface SizeOptions { /** * name property will be appended to the file name of the scaled file */ name: string; /** * maximum size */ maxSize: number; /** * MIME type */ type?: string; } /** * ScalingOptions */ interface ScalingOptions { /** * Ignored if the current browser does not support image previews. * * If you want to use an alternate scaling library, you must contribute a function for this option that returns a Promise. * Once the resize is complete, your promise must be fulfilled. You may, of course, reject your returned Promise is the resize fails in some way * * @default `undefined` */ customResizer?: CustomResizerCallBack; /** * A value between `1` and `100` that describes the requested quality of scaled images. * * Ignored unless the scaled image type target is `image/jpeg` * * @default `80` */ defaultQuality?: number /** * Scaled images will assume this image type if you don't specify a specific type in your size object, or if the type specified in the size object is not valid. * * You generally should not use any value other than `image/jpeg` or `image/png` here. * * The default value of null will ensure the scaled image type is `PNG`, unless the original file is a `JPEG`, in which case the scaled file will also be a `JPEG`. * The default is probably the safest option. * * @default `null` */ defaultType?: string; /** * Text sent to your `complete` event handler as an `error` property of the `response` param if a scaled image could not be generated * * @default `'failed to scale'` */ failureText?: string; /** * Ensure the `EXIF` data from the reference image is inserted into the scaled image. Only applicable when both the reference and the target are type `image/jpeg` * * @default `false` */ includeExif?: boolean; /** * Set this to `false` if you do not want scaled images to be re-oriented based on parsed `EXIF` data before they are uploaded * * @default `true` */ orient?: boolean; /** * Set this to `false` if you don't want to original file to be uploaded as well * * @default `true` */ sendOriginal?: boolean; /** * An array containing size objects that describe scaled versions of each submitted image that should be generated and uploaded * * @default `[]` */ sizes?: SizeOptions; } /** * SessionOptions */ interface SessionOptions { /** * Any additional headers you would like included with the `GET` request sent to your server. Ignored in `IE9` and `IE8` if the endpoint is cross-origin * * @default `{}` */ customHeaders?: any; /** * If non-null, Fine Uploader will send a `GET` request on startup to this endpoint, expecting a `JSON` response containing data about the initial file list to populate * * @default `null` */ endpoint?: string; /** * Any parameters you would like passed with the associated `GET` request to your server * * @default `{}` */ params?: any; /** * Set this to `false` if you do not want the file list to be retrieved from the server as part of a reset. * * @default `true` */ refreshOnReset?: boolean } /** * TextOptions */ interface TextOptions { /** * In the event of non-200 response from the server sans the 'error' property, this message will be passed to the 'error' event handler * * @default `'Upload failure reason unknown'` */ defaultResponseError?: string; /** * The value for the `title` attribute attached to the `` maintained by Fine Uploader for each upload button. * * This is used as hover text, among other things. * * @default `'file input'` */ fileInputTitle?: string; /** * Symbols used to represent file size, in ascending order * * @default `['kB', 'MB', 'GB', 'TB', 'PB', 'EB']` */ sizeSymbols?: string[]; } /** * ImageOptions */ interface ImageOptions { /** * Restrict images to a maximum height in pixels (wherever possible) * * @default `0` */ maxHeight?: number; /** * Restrict images to a maximum width in pixels (wherever possible) * * @default `0` */ maxWidth?: number; /** * Restrict images to a minimum height in pixels (wherever possible) * * @default `0` */ minHeight?: number; /** * Restrict images to a minimum width in pixels (wherever possible) * * @default `0` */ minWidth?: number; } /** * ValidationOptions */ interface ValidationOptions { /** * Used by the file selection dialog. * * Restrict the valid file types that appear in the selection dialog by listing valid content-type specifiers * * @default `null` */ acceptFiles?: any; /** * Specify file valid file extensions here to restrict uploads to specific types * * @default `[]` */ allowedExtensions?: string[]; /** * Maximum number of items that can be potentially uploaded in this session. * * Will reject all items that are added or retried after this limit is reached * * @default `0` */ itemLimit?: number; /** * The minimum allowable size, in bytes, for an item * * @default `0` */ minSizeLimit: number; /** * The maximum allowable size, in bytes, for an item * * @default `0` */ sizeLimit?: number; /** * When `true` the first invalid item will stop processing further files * * @default `true` */ stopOnFirstInvalidFile?: boolean; /** * ImageOptions */ image?: ImageOptions; } /** * WorkArounds options */ interface WorkArounds { /** * Ensures all `` elements tracked by Fine Uploader do NOT contain a `multiple` attribute to work around an issue present in iOS7 & 8 that otherwise results in 0-sized uploaded videos * * @default `true` */ iosEmptyVideos?: boolean; /** * Ensures all `` elements tracked by Fine Uploader always have a `multiple` attribute present. * * This only applies to iOS8 Chrome and iOS8 UIWebView, and is put in place to work around an issue that causes the browser to crash when a file input element does not contain a `multiple` attribute inside of a `UIWebView` container created by an iOS8 app compiled with and iOS7 SDK * * @default `false` */ ios8BrowserCrash?: boolean; /** * Disables Fine Uploader and displays a message to the user in iOS 8.0.0 Safari. * * Due to serious bugs in iOS 8.0.0 Safari, uploading is not possible. * This was apparently fixed in subsequent builds of iOS8, so this workaround only targets 8.0.0 * * @default `true` */ ios8SafariUploads?: boolean; } /* ====================================== Core Callback functions ==================================== */ /** * onAutoRetry function type */ interface OnAutoRetry { /** * @param number id : The current file's id * @param string name : The current file's name * @param number attemptNumber : The number of retry attempts for the current file so far */ (id: number, name: string, attemptNumber: number): void; } /** * onCancel function type */ interface OnCancel { /** * @param number id : The current file's id * @param string name : The current file's name */ (id: number, name: string): boolean | Promise | void; } /** * onComplete function type */ interface OnComplete { /** * @param number id : The current file's id * @param string name : The current file's name * @param Object responseJSON : The raw response from the server * @param XMLHttpRequest xhr : The object used to make the request */ (id: number, name: string, responseJSON: any, xhr: XMLHttpRequest): void; } /** * onAllComplete function type */ interface OnAllComplete { /** * @param number[] succeeded : IDs of all files in the group that have uploaded successfully (status = `qq.status.UPLOAD_SUCCESSFUL`) * @param number[] failed : IDs of all files in the group that have failed (status = `qq.status.UPLOAD_FAILED`) */ (succeeded: number[], failed: number[]): void; } /** * onDelete function type */ interface OnDelete { /** * @param number id : The current file's id */ (id: number): void; } /** * onDeleteComplete function type */ interface OnDeleteComplete { /** * @param number id : The current file's id * @param XMLHttpRequest xhr : The object used to make the request * @param boolean isError : `true` if there has been an error, `false` otherwise */ (id: number, xhr: XMLHttpRequest, isError: boolean): void; } /** * onError function type */ interface OnError { /** * @param number id : The current file's id * @param string name : The current file's name * @param string errorReason : The reason for the current error * @param XMLHttpRequest xhr : The object used to make the request */ (id: number, name: string, errorReason: string, xhr: XMLHttpRequest): void; } /** * onManualRetry function type */ interface OnManualRetry { /** * @param number id : The current file's id * @param string name : The current file's name */ (id: number, name: string): boolean | void; } /** * onPasteReceived function type */ interface OnPasteReceived { /** * @param Blob blob : An object encapsulating the image pasted from the clipboard */ (blob: Blob): Promise | void; } /** * onProgress function type */ interface OnProgress { /** * @param number id : The current file's id * @param string name : The current file's name * @param number uploadedBytes : The number of bytes that have been uploaded so far * @param number totalBytes : The total number of bytes that comprise this file */ (id: number, name: string, uploadedBytes: number, totalBytes: number): void; } /** * onResume function type */ interface OnResume { /** * @param number id : The current file's id * @param string name : The current file's name * @param Object chunkData : The chunk that will be sent next when file upload resumes */ (id: number, name: string, chunkData: any): void; } /** * onSessionRequestComplete function type */ interface OnSessionRequestComplete { /** * @param any[] response : The raw response data * @param boolean success : Indicates whether success has been achieved or not * @param XMLHttpRequest xhrOrXdr : The raw request */ (response: any[], success: boolean, xhrOrXdr: XMLHttpRequest): void; } /** * onStatusChange function type */ interface OnStatusChange { /** * @param number id : The current file's id * @param string oldStatus : The previous item status * @param string newStatus : The new status of the item */ (id: number, oldStatus: string, newStatus: string): void; } /** * onSubmit function type */ interface OnSubmit { /** * @param number id : The current file's id * @param string name : The current file's name */ (id: number, name: string): boolean | Promise | void; } /** * onSubmitDelete function type */ interface OnSubmitDelete { /** * @param number id : The current file's id */ (id: number): Promise | void; } /** * onSubmitted function type */ interface OnSubmitted { /** * @param number id : The current file's id * @param string name : The current file's name */ (id: number, name: string): void; } /** * onTotalProgress function type */ interface OnTotalProgress { /** * @param number totalUploadedBytes : The number of bytes that have been uploaded so far in this batch * @param number totalBytes : The total number of bytes that comprise all files in the batch */ (totalUploadedBytes: number, totalBytes: number): void; } /** * onUpload function type */ interface OnUpload { /** * @param number id : The current file's id * @param string name : The current file's name */ (id: number, name: string): void; } /** * properties for chunkData object */ interface ChunkData { /** * the 0-based index of the associated partition */ partIndex: number; /** * the byte offset of the current chunk */ startByte: number; /** * the last byte of the current chunk */ endByte: number; /** * the total number of partitions associated with the `File` or `Blob` */ totalParts: number; } /** * onUploadChunk function type */ interface OnUploadChunk { /** * @param number id : The current file's id * @param string name : The current file's name * @param ChunkData chunkData : An object encapsulating the current chunk of data about to be uploaded */ (id: number, name: string, chunkData: ChunkData): void; } /** * onUploadChunkSuccess function type */ interface OnUploadChunkSuccess { /** * @param number id : The current file's id * @param ChunkData chunkData : An object encapsulating the current chunk of data about to be uploaded * @param Object responseJSON : The raw response from the server * @param XMLHttpRequest xhr : The object used to make the request */ (id: number, chunkData: ChunkData, responseJSON: any, xhr: XMLHttpRequest): void; } /** * blobData object */ interface BlobDataObject { /** * the name of the file */ name: string; /** * the size of the file */ size: number; } /** * onValidate function type */ interface OnValidate { /** * @param BlobDataObject data : An object with a name and size property * @param HTMLElement buttonContainer : The button corresponding to the respective file if the file was submitted to Fine Uploader using a tracked button */ (data: BlobDataObject, buttonContainer?: HTMLElement): Promise | void; } /** * onValidateBatch function type */ interface OnValidateBatch { /** * @param BlobDataObject[] fileOrBlobDataArray : An array of Objects with name and size properties * @param HTMLElement buttonContainer : The button corresponding to the respective file if the file was submitted to Fine Uploader using a tracked button */ (fileOrBlobDataArray: BlobDataObject[], buttonContainer: HTMLElement): Promise | void; } /** * Core callback functions */ interface CoreEvents { /** * **Called before each automatic retry attempt for a failed item** */ onAutoRetry?: OnAutoRetry; /** * **Called when the item has been canceled. Return `false` to prevent the upload from being canceled.** * * Also can return a promise if non-blocking work is required here. Calling `failure()` on the promise is equivalent to returning `false`. * * If using a Promise, then processing of the cancel request will be deferred until the promise is fullfilled. * * Since there is no way to 'pause' the upload in progress while waiting for the promise to be fullfilled the upload may actually complete until the promise has actually be fullfilled */ onCancel?: OnCancel; /** * **Called when the item has finished uploading.** * * The `responseJSON` will contain the raw response from the server including the 'success' property which indicates whether the upload succeeded. */ onComplete?: OnComplete; /** * **Called when all submitted items have reached a point of termination.** * * A file has reached a point of termination if it has been cancelled, rejected, or uploaded (failed or successful). * * For example, if a file in the group is paused, and all other files in the group have uploaded successfully the allComplete event will not be invoked for the group until that paused file is either continued and completes the uploading process, or canceled. * * This event will not be called if all files in the group have been cancelled or rejected (i.e. if none of the files have reached a status of `qq.status.UPLOAD_SUCCESSFUL` or `qq.status.UPLOAD_FAILED`) */ onAllComplete?: OnAllComplete; /** * **Called just before a delete request is sent for the associated item.** * * ###Note: * This is not the correct callback to influence the delete request. * To do that, use the `onSubmitDelete` callback instead */ onDelete?: OnDelete; /** * **Called just after receiving a response from the server for a delete file request** */ onDeleteComplete?: OnDeleteComplete; /** * **Called whenever an exceptional condition occurs** */ onError?: OnError; /** * **Called before each manual retry attempt.** * * Return `false` to prevent this and all future retry attempts on the associated item */ onManualRetry?: OnManualRetry; /** * **Called when a pasted image has been received (before upload).** * * The pasted image is represented as a `Blob`. Also can return a `Promise` if non-blocking work is required here. * * If using a `Promise` the value of the success parameter must be the name to associate with the pasted image. * * If the associated attempt is marked a failure then you should include a string explaining the reason in your failure callback for the `Promise` * * ###NOTE: * The `promptForName` option, if `true`, will effectively wipe away any custom implementation of this callback. * * The two are not meant to be used together. This callback is meant to provide an alternative means to provide a name for a pasted image. * * If you are using Fine Uploader Core mode then you can display your own prompt for the name by overriding the default implementation of this callback */ onPasteReceived?: OnPasteReceived; /** * **Called during the upload, as it progresses, but only for the AJAX uploader.** * * For chunked uploads, this will be called for each chunk. * Useful for implementing a progress bar */ onProgress?: OnProgress; /** * **Called just before an upload is resumed.** * * See the `uploadChunk` event for more info on the `chunkData` object */ onResume?: OnResume; /** * **Invoked when a session request has completed.** * * The `response` will be either an `Array` containing the response data or `null` if the response did not contain valid `JSON`. * * The `success` parameter will be `false` if ANY of the file items represented in the response could not be parsed (due to bad syntax, missing name/UUID property, etc) */ onSessionRequestComplete?: OnSessionRequestComplete; /** * **Invoked whenever the status changes for any item submitted by the uploader.** * * The status values correspond to those found in the `qq.status` object. * * For reference: * * `SUBMITTED` * * `QUEUED` * * `UPLOADING` * * `UPLOAD_RETRYING` * * `UPLOAD_FAILED` * * `UPLOAD_SUCCESSFUL` * * `CANCELED` * * `REJECTED` * * `DELETED` * * `DELETING` * * `DELETE_FAILED` * * `PAUSED` */ onStatusChange?: OnStatusChange; /** * **Called when the item has been selected and is a candidate for uploading** * * This does not mean the item is going to be uploaded. Return `false` to prevent submission to the uploader. * * A promise can be used if non-blocking work is required. Processing of this item is deferred until the promise is fullfilled. * * If a promise is returned, a call to failure is the same as returning `false` */ onSubmit?: OnSubmit; /** * **Called before an item has been marked for deletion has been submitted to the uploader** * * A promise can be used if non-blocking work is required. * Processing of this item is deferred until the promise is fullfilled. * If a promise is returned, a call to failure is the same as returning `false`. * * Use this callback to influence the delete request. * For example, you can change the custom parameters sent with the underlying delete request using the `setDeleteParams` API method */ onSubmitDelete?: OnSubmitDelete; /** * **Called when the item has been successfully submitted to the uploader.** * * The file will upload immediately if there is: * * a) at least one free connection (see: maxConnections option) and * * b) autoUpload is set to true (see autoUpload option) * * The callback is invoked after the 'submit' event is handled without returning a false value. * * In Fine Uploader Core mode it is usually safe to assume that the associated elements in the UI representing the associated file have already been added to the DOM immediately before this callback is invoked */ onSubmitted?: OnSubmitted; /** * **Called during a batch of uploads, as they progress, but only for the AJAX uploader.** * * This represents the total progress of all files in the batch. Useful for implementing an aggregate progress bar. */ onTotalProgress?: OnTotalProgress; /** * **Called just before an item begins uploading to the server.** */ onUpload?: OnUpload; /** * **Called just before a chunk request is sent.** */ onUploadChunk?: OnUploadChunk; /** * **This is similar to the `complete` event, except it is invoked after each chunk has been successfully uploaded.** * * See the `uploadChunk` event for more information on the `chunkData` object */ onUploadChunkSuccess?: OnUploadChunkSuccess; /** * **Called once for each selected, dropped, or `addFiles` submitted file.** * * This callback is always invoked before the default Fine Uploader validators execute. * * This event will not be called if you return `false` in your `validateBatch` event handler, or if the `stopOnFirstInvalidFile` validation option is `true` and the `validate` event handler has returned `false` for an item. * * A promise can be used if non-blocking work is required. Processing of this item is deferred until the promise is fullfilled. * If a promise is returned, a call to `failure` is the same as returning `false`. * * A buttonContainer element will be passed as the last argument, provided the file was submitted using a Fine Uploader tracked button. * * The `blobData` object has two properties: `name` and `size`. The `size` property will be undefined for browsers without File API support. */ onValidate?: OnValidate; /** * **This callback is always invoked before the default Fine Uploader validators execute.** * * This event will not be called if you return `false` in your `validateBatch` event handler, or if the `stopOnFirstInvalidFile` validation option is `true` and the `validate` event handler has returned `false` for an item. * * A promise can be used if non-blocking work is required. Processing of this item is deferred until the promise is fullfilled. If a promise is returned, a call to `failure` is the same as returning `false`. * * A buttonContainer element will be passed as the last argument, provided the file was submitted using a Fine Uploader tracked button. * * The `fileOrBlobDataArray` object has two properties: `name` and `size`. The `size` property will be undefined for browsers without File API support. */ onValidateBatch?: OnValidateBatch; } /* ====================================== END - Core Callback functions ======================================== */ /** * Contains Core options */ interface CoreOptions { /** * Set to false if you want to be able to upload queued items later by calling the `uploadStoredFiles()` method * * @default `true` */ autoUpload?: boolean; /** * Specify an element to use as the 'select files' button. Cannot be a `