mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
fine-uploader: Provides its own types (#14983)
This commit is contained in:
Vendored
-346
@@ -1,346 +0,0 @@
|
||||
// Type definitions for FineUploader for 5.11
|
||||
// Project: http://fineuploader.com/
|
||||
// Definitions by: Bradford Wagner <https://github.com/bradfordwagner/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace qq {
|
||||
interface BlobsOptions {
|
||||
defaultName?: string;
|
||||
}
|
||||
|
||||
interface CameraOptions {
|
||||
button?: HTMLElement;
|
||||
ios?: boolean;
|
||||
}
|
||||
|
||||
interface ChunkingOptions {
|
||||
concurrent?: ChunkingConcurrentOptions;
|
||||
enabled?: boolean; // default false
|
||||
mandatory?: boolean; // default false
|
||||
partSize?: number; // default 2,000,000
|
||||
paramNames?: ChunkingParamNames;
|
||||
success?: ChunkingSuccess;
|
||||
}
|
||||
|
||||
interface ChunkingConcurrentOptions {
|
||||
enabled?: boolean; // default false
|
||||
}
|
||||
|
||||
interface ChunkingParamNames {
|
||||
chunkSize?: string; // default: qqchunksize
|
||||
partByteOffset?: string; // default: qqpartbyteoffset
|
||||
partIndex?: string; // default: qqpartindex
|
||||
totalParts?: string; // default: qqtotalparts
|
||||
}
|
||||
|
||||
interface ChunkingSuccess {
|
||||
endpoint?: string | null; // default: null
|
||||
}
|
||||
|
||||
interface CorsOptions {
|
||||
allowXdr?: boolean; // default: false
|
||||
expected?: boolean; // default: false
|
||||
sendCredentials: boolean; // default: false
|
||||
}
|
||||
|
||||
interface DeleteFileOptions<H, P> {
|
||||
customHeader?: H; // default: {}
|
||||
enabled?: boolean; // default false
|
||||
endpoint?: string; // default: /server/upload
|
||||
method?: string; // default: DELETE
|
||||
params?: P; // default: {}
|
||||
}
|
||||
|
||||
interface ExtraButtonsOptions<V> {
|
||||
element: HTMLElement | undefined; // default: undefined
|
||||
fileInputTitle?: string; // default: file input
|
||||
folders?: boolean; // default: false
|
||||
multiple?: boolean; // default: true
|
||||
validation?: V; // default: 'validation'
|
||||
}
|
||||
|
||||
interface FormOptions {
|
||||
element?: string | HTMLElement; // default: qq-form
|
||||
autoUpload?: boolean; // default: false
|
||||
interceptSubmit?: boolean; // default: true
|
||||
}
|
||||
|
||||
interface MessagesOptions {
|
||||
emptyError?: string; // default: {file} is empty, please select files again without it.
|
||||
maxHeightImageError?: string; // default: Image is too tall.
|
||||
maxWidthImageError?: string; // default: Image is too wide.
|
||||
minHeightImageError?: string; // default: Image is not tall enough.
|
||||
minWidthImageError?: string; // default: Image is not wide enough.
|
||||
minSizeError?: string; // default: {file} is too small, minimum file size is {minSizeLimit}.
|
||||
noFilesError?: string; // default: No files to upload.
|
||||
onLeave?: string; // default: The files are being uploaded, if you leave now the upload will be canceled.
|
||||
retryFailTooManyItemsError?: string; // default: Too many items ({netItems}) would be uploaded. Item limit is {itemLimit}.
|
||||
typeError?: string; // default: {file} has an invalid extension. Valid extension(s): {extensions}.
|
||||
// tslint:disable-next-line:max-line-length
|
||||
unsupportedBrowserIos8Safari?: string; // 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.
|
||||
}
|
||||
|
||||
interface PasteOptions {
|
||||
defaultName?: string; // default: pasted_image
|
||||
targetElement?: HTMLElement | null; // default: null
|
||||
}
|
||||
|
||||
interface ResumeOptions {
|
||||
recordsExpireIn?: number; // default: 7
|
||||
enabled?: boolean; // default: false
|
||||
paramNames?: ResumeParamNameOptions;
|
||||
}
|
||||
|
||||
interface ResumeParamNameOptions {
|
||||
resuming: string; // default: qqresume
|
||||
}
|
||||
|
||||
interface RetryOptions {
|
||||
autoAttemptDelay?: number; // default: 5
|
||||
enableAuto?: boolean; // default: false
|
||||
maxAutoAttempts?: number; // default: 3
|
||||
preventRetryResponseProperty?: string; // default: preventRetry
|
||||
}
|
||||
|
||||
interface RequestOptions <H, P> {
|
||||
customHeaders?: H; // default: {}
|
||||
endpoint?: string; // default: /server/upload
|
||||
filenameParam?: string; // default: qqfilename
|
||||
forceMultipart?: boolean; // default: true
|
||||
inputName?: string; // default: qqfile
|
||||
method?: string; // default: POST
|
||||
params?: P; // default: {}
|
||||
paramsInBody?: boolean; // default: true
|
||||
uuid?: string; // default: qquuid
|
||||
totalFileSizeName?: string; // default: qqtotalfilesize
|
||||
}
|
||||
|
||||
interface ScalingOptions {
|
||||
customResizer?: (
|
||||
blob: File | Blob,
|
||||
height: number,
|
||||
image: HTMLImageElement,
|
||||
sourceCanvas: HTMLCanvasElement,
|
||||
targetCanvas: HTMLCanvasElement,
|
||||
width: number) => Promise<File | Blob> | undefined; // default: undefined
|
||||
defaultQuality?: number; // default: 80
|
||||
defaultType?: string | null; // default: null
|
||||
failureText?: string; // default: Failed to scale
|
||||
includeExif?: boolean; // default: false
|
||||
orient?: boolean; // default: true
|
||||
sendOriginal?: boolean; // default: false
|
||||
sizes?: Size[]; // default: []
|
||||
}
|
||||
|
||||
/**
|
||||
* From Documentation:
|
||||
* An array containing size objects that describe scaled versions of each submitted image that should be generated and uploaded.
|
||||
* A size object should usually contain a name String property (which will be appended to the file name of the scaled file), and must always contain a maxSize integer property.
|
||||
* A type MIME string property is optional.
|
||||
*/
|
||||
interface Size {
|
||||
name: string;
|
||||
maxSize: number;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
interface SessionOptions<H, P> {
|
||||
customHeaders?: H; // default: {}
|
||||
endpoint?: string | null; // default: null
|
||||
params?: P; // default: {}
|
||||
refreshOnReset?: boolean; // default: true
|
||||
}
|
||||
|
||||
interface TextOptions {
|
||||
defaultResponseError?: string; // default: Upload failure reason unknown
|
||||
fileInputTitle?: string; // default: file input
|
||||
sizeSymbols?: string[]; // default: ['kB', 'MB', 'GB', 'TB', 'PB', 'EB']
|
||||
}
|
||||
|
||||
interface ValidationOptions {
|
||||
acceptFiles?: MimeType[] | null; // default: null
|
||||
allowedExtensions?: string[]; // default: []
|
||||
itemLimit?: number; // default: 0
|
||||
minSizeLimit?: number; // default: 0
|
||||
sizeLimit?: number; // default: 0
|
||||
stopOnFirstInvalidFile?: boolean; // default: true
|
||||
image?: ValidationImageOptions;
|
||||
}
|
||||
|
||||
interface ValidationImageOptions {
|
||||
maxHeight?: number; // default: 0
|
||||
maxWidth?: number; // default: 0
|
||||
minWidth?: number; // default: 0
|
||||
minHeight?: number; // default: 0
|
||||
}
|
||||
|
||||
interface WorkaroundOptions {
|
||||
iosEmptyVideos?: boolean; // default: true
|
||||
ios8BrowserCrash?: boolean; // default: false
|
||||
ios8SafariUploads?: boolean; // default: true
|
||||
}
|
||||
|
||||
interface ChunkData {
|
||||
partIndex: number;
|
||||
startByte: number;
|
||||
endByte: number;
|
||||
totalParts: number;
|
||||
}
|
||||
|
||||
interface ValidateMetadata {
|
||||
name: string;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
interface CallbackOptions {
|
||||
onAutoRetry?: (id: number, name: string, attemptNumber: number) => void;
|
||||
onCancel?: (id: number, name: string) => void;
|
||||
onComplete?: <T>(id: number, name: string, responseJSON: T, xhr: XMLHttpRequest) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript
|
||||
onAllComplete?: (succeeded: number[], failed: number[]) => void;
|
||||
onDelete?: (id: number) => void;
|
||||
onDeleteComplete?: (id: number, xhr: XMLHttpRequest, isError: boolean) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript
|
||||
onError?: (id: number, name: string, errorReason: string, xhr: XMLHttpRequest) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript
|
||||
onManualRetry?: (id: number, name: string) => boolean; // return false to prevent this and all future retries
|
||||
onPasteReceived?: (blob: Blob) => void;
|
||||
onProgress?: (id: number, name: string, uploadedBytes: number, totalBytes: number) => void;
|
||||
onResume?: <T>(id: number, name: string, chunkData: T) => void;
|
||||
onSessionRequestComplete?: <T>(response: T[], success: boolean, xhrOrXdr: XMLHttpRequest) => void; // ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript
|
||||
onStatusChange?: (id: number, oldStatus: string, newStatus: string) => void;
|
||||
onSubmit?: (id: number, name: string) => void;
|
||||
onSubmitDelete?: (id: number) => void;
|
||||
onSubmitted?: (id: number, name: string) => void;
|
||||
onTotalProgress?: (totalUploadedBytes: number, totalBytes: number) => void;
|
||||
onUpload?: (id: number, name: string) => void;
|
||||
onUploadChunk?: (id: number, name: string, chunkData: ChunkData) => void;
|
||||
// ignore xhr: XDomainRequest as it is not compatible for all versions of TypeScript
|
||||
onUploadChunkSuccess?: <T>(id: number, chunkData: ChunkData, responseJSON: T, xhr: XMLHttpRequest) => void;
|
||||
onValidate?: (data: ValidateMetadata, buttonContainer: HTMLElement) => void;
|
||||
onValidateBatch?: (fileOrBlobDataArray: ValidateMetadata[], buttomContainer: HTMLElement) => void;
|
||||
}
|
||||
|
||||
interface BasicOptions {
|
||||
// core options
|
||||
autoUpload?: boolean; // default true
|
||||
button?: HTMLElement;
|
||||
debug?: boolean;
|
||||
disableCancelForFormUploads?: boolean;
|
||||
formatFileName?: (rawFileName: string) => string; // rawFilename to display filename
|
||||
maxConnections?: number;
|
||||
multiple?: boolean;
|
||||
|
||||
blobs?: BlobsOptions;
|
||||
camera?: CameraOptions;
|
||||
chunking?: ChunkingOptions;
|
||||
cors?: CorsOptions;
|
||||
deleteFile?: DeleteFileOptions<any, any>;
|
||||
extraButtons?: ExtraButtonsOptions<any>;
|
||||
form?: FormOptions;
|
||||
messages?: MessagesOptions;
|
||||
paste?: PasteOptions;
|
||||
resume?: ResumeOptions;
|
||||
retry?: RetryOptions;
|
||||
request?: RequestOptions<any, any>;
|
||||
scaling?: ScalingOptions;
|
||||
session?: SessionOptions<any, any>;
|
||||
text?: TextOptions;
|
||||
validation?: ValidationOptions;
|
||||
workarounds?: WorkaroundOptions;
|
||||
|
||||
callbacks?: CallbackOptions;
|
||||
}
|
||||
|
||||
interface BlobWrapper {
|
||||
blob: Blob;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface CanvasWrapper {
|
||||
canvas: HTMLCanvasElement;
|
||||
name: string;
|
||||
quality: number; // 1-100
|
||||
type: MimeType;
|
||||
}
|
||||
|
||||
interface ResizeInfo {
|
||||
blob: File | Blob;
|
||||
height: number;
|
||||
image: HTMLImageElement;
|
||||
sourceCanvas: HTMLCanvasElement;
|
||||
targetCanvas: HTMLCanvasElement;
|
||||
width: number;
|
||||
}
|
||||
|
||||
interface ResumableItem {
|
||||
name: string;
|
||||
uuid: string;
|
||||
partIdx: number;
|
||||
}
|
||||
|
||||
interface FilterOption {
|
||||
id?: number;
|
||||
uuid?: string;
|
||||
originalName?: string;
|
||||
name?: string;
|
||||
status?: string;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
interface ScaleImageOptions {
|
||||
maxSize: number;
|
||||
orient?: boolean; // default: true
|
||||
type?: string; // default: type or reference image
|
||||
quality?: number; // 0-100 - default: 80
|
||||
includeExif?: boolean; // default: false
|
||||
customResizer?: (resizeInfo: ResizeInfo) => Promise<File | Blob>;
|
||||
}
|
||||
|
||||
class FineUploaderBasic {
|
||||
constructor(options: BasicOptions)
|
||||
|
||||
addFiles<T>(files: File[] | HTMLInputElement[] | Blob[] | BlobWrapper[] | HTMLCanvasElement[] | CanvasWrapper[] | FileList, params: T, endpoint: string): void;
|
||||
addInitialFiles<T>(initialFiles: T[]): void;
|
||||
cancel(id: number): void;
|
||||
cancelAll(): void;
|
||||
clearStoredFiles(): void;
|
||||
continueUpload(id: number): boolean; // true if successful
|
||||
deleteFile(id: number): void;
|
||||
|
||||
/**
|
||||
* TODO: need someone who has used this to update the returned promise related fields
|
||||
*/
|
||||
drawThumbnail(id: number, targetContainer: HTMLElement, maxSize: number, fromServer: boolean, customResizer: (resizeInfo: ResizeInfo) => Promise<File | Blob>): Promise<any>
|
||||
getButton(id: number): HTMLElement;
|
||||
getFile(id: number): File | Blob;
|
||||
getInProgress(): number;
|
||||
getName(id: number): string;
|
||||
getParentId(scaledFileId: number): number;
|
||||
getRemainingAllowedItems(): number;
|
||||
getResumableFilesData(): ResumableItem[];
|
||||
getSize(id: number): number;
|
||||
getUploads<T>(filter: FilterOption): T | T[];
|
||||
getUuid(id: number): string;
|
||||
log(message: string, level: string): void;
|
||||
pauseUpload(id: number): boolean; // true if successful
|
||||
reset(): void;
|
||||
retry(id: number): void;
|
||||
scaleImage(id: number, options: ScaleImageOptions): Promise<Blob>;
|
||||
setCustomHeaders<H>(customHeaders: H, id: number): void;
|
||||
setEndpoint(path: string, identifier: number | HTMLElement): void;
|
||||
setDeleteFileCustomHeaders<H>(customHeaders: H, id: number): void;
|
||||
setDeleteFileEndpoint(path: string, identifier: number | HTMLElement): void;
|
||||
setDeleteFileParams<P>(params: P, id: number): void;
|
||||
setItemLimit(newItemLimit: number): void;
|
||||
setForm(formElementOrId: HTMLFormElement | string): void;
|
||||
setName(id: number, name: string): void;
|
||||
setParams<P>(params: P, id: number): void;
|
||||
setUuid(id: number, uuid: string): void;
|
||||
uploadStoredFiles(): void; // throws NoFilesError
|
||||
|
||||
// ui
|
||||
addExtraDropzone(element: HTMLElement): void;
|
||||
getDropTarget(id: number): HTMLElement;
|
||||
getId(element: HTMLElement): number;
|
||||
getItemByFileId(id: number): HTMLElement;
|
||||
removeExtraDropzone(element: HTMLElement): void;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
function testBlob() {
|
||||
const config: qq.BasicOptions = {
|
||||
blobs: {
|
||||
defaultName: "hi.png"
|
||||
}
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
class CallbacksTest {
|
||||
constructor(private opts: qq.CallbackOptions) {
|
||||
|
||||
}
|
||||
|
||||
testCallbacks() {
|
||||
const opts = this.opts;
|
||||
|
||||
interface CustomType {
|
||||
myTypeOfClass: string;
|
||||
}
|
||||
|
||||
opts.onAutoRetry = (id, name, attemptNumber) => {};
|
||||
|
||||
opts.onCancel = (id, name) => {};
|
||||
|
||||
opts.onComplete = (id: number, name: string, responseJSON: CustomType, xhr: XMLHttpRequest) => {};
|
||||
|
||||
opts.onAllComplete = (succeeded, failed) => {};
|
||||
|
||||
opts.onDelete = (id) => {};
|
||||
|
||||
opts.onDeleteComplete = (id, xhr, isError) => {};
|
||||
|
||||
opts.onError = (id, name, errorReason, xhr) => {};
|
||||
|
||||
opts.onManualRetry = (id, name) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
opts.onPasteReceived = (blob) => {};
|
||||
|
||||
opts.onProgress = (id, name, uploadedBytes, totalBytes) => {};
|
||||
|
||||
opts.onResume = (id: number, name: string, chunkData: CustomType) => {};
|
||||
|
||||
opts.onSessionRequestComplete = (response: CustomType[], success: boolean, xhrOrXdr: XMLHttpRequest) => {};
|
||||
|
||||
opts.onStatusChange = (id, oldStatus, newStatus) => {};
|
||||
|
||||
opts.onSubmit = (id, name) => {};
|
||||
|
||||
opts.onSubmitDelete = (id) => {};
|
||||
|
||||
opts.onSubmitted = (id, name) => {};
|
||||
|
||||
opts.onTotalProgress = (totalUploadedBytes, totalBytes) => {};
|
||||
|
||||
opts.onUpload = (id, name) => {};
|
||||
|
||||
opts.onUploadChunk = (id, name, chunkData) => {};
|
||||
|
||||
opts.onUploadChunkSuccess = (id: number, chunkData: qq.ChunkData, responseJSON: CustomType, xhr: XMLHttpRequest) => {};
|
||||
|
||||
opts.onValidate = (data, buttonContainer) => {};
|
||||
|
||||
opts.onValidateBatch = (fileOrBlobDataArray, buttonContaine) => {};
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
function cameraTest() {
|
||||
const cameraButton = new HTMLButtonElement();
|
||||
|
||||
const cameraOptions: qq.CameraOptions = {
|
||||
button: cameraButton,
|
||||
ios: false
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
camera: cameraOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
function chunkingTest() {
|
||||
|
||||
const chunkingOptions: qq.ChunkingOptions = {
|
||||
concurrent: {
|
||||
enabled: false
|
||||
},
|
||||
enabled: true,
|
||||
mandatory: true,
|
||||
partSize: 1000000,
|
||||
paramNames: {
|
||||
chunkSize: "chunkSize",
|
||||
partByteOffset: "partByteOffset",
|
||||
partIndex: "partIndex",
|
||||
totalParts: "totalParts"
|
||||
},
|
||||
success: {
|
||||
endpoint: "/some/web/endpoint/yaySuccesss"
|
||||
}
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
chunking: chunkingOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
function testCore() {
|
||||
const button: HTMLElement = new HTMLButtonElement();
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
autoUpload: true,
|
||||
button,
|
||||
debug: true,
|
||||
disableCancelForFormUploads: true,
|
||||
formatFileName: (rawFileName: string) => {
|
||||
return "hi";
|
||||
},
|
||||
maxConnections: 10,
|
||||
multiple: true
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
function corsTest() {
|
||||
const corsOptions: qq.CorsOptions = {
|
||||
allowXdr: true,
|
||||
expected: true,
|
||||
sendCredentials: true
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
cors: corsOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
function deleteFileTest() {
|
||||
interface CustomHeader {
|
||||
myOption: string;
|
||||
}
|
||||
|
||||
interface CustomParams {
|
||||
myParam: string;
|
||||
}
|
||||
|
||||
const deleteFileOptions: qq.DeleteFileOptions<CustomHeader, CustomParams> = {
|
||||
customHeader: {
|
||||
myOption: "ewwww"
|
||||
},
|
||||
enabled: true,
|
||||
endpoint: "/my/server/location/delete",
|
||||
method: "POST",
|
||||
params: {
|
||||
myParam: "u"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
deleteFile: deleteFileOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
function extraButtons() {
|
||||
interface Validation {
|
||||
myValue: string;
|
||||
}
|
||||
|
||||
const element: HTMLElement = new HTMLElement();
|
||||
|
||||
const extraButtonOptions: qq.ExtraButtonsOptions<Validation> = {
|
||||
element,
|
||||
fileInputTitle: "inputTitle",
|
||||
folders: true,
|
||||
multiple: false,
|
||||
validation: {
|
||||
myValue: "ew"
|
||||
}
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
extraButtons: extraButtonOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
function formTest() {
|
||||
const formOptions: qq.FormOptions = {
|
||||
element: "qq-form",
|
||||
autoUpload: true,
|
||||
interceptSubmit: true
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
form: formOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
function messageTest() {
|
||||
const messageOptions: qq.MessagesOptions = {
|
||||
emptyError: "emptyError",
|
||||
maxHeightImageError: "maxHeightImageError",
|
||||
maxWidthImageError: "error occurred",
|
||||
minHeightImageError: "error occurred",
|
||||
minWidthImageError: "error occurred",
|
||||
minSizeError: "error occurred",
|
||||
noFilesError: "error occurred",
|
||||
onLeave: "error occurred",
|
||||
retryFailTooManyItemsError: "error occurred",
|
||||
typeError: "error occurred",
|
||||
unsupportedBrowserIos8Safari: "error occurred"
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
messages: messageOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
class TestMethods {
|
||||
constructor(private uploader: qq.FineUploaderBasic) {
|
||||
}
|
||||
|
||||
testAddFiles() {
|
||||
interface ParamType {
|
||||
field: string;
|
||||
}
|
||||
|
||||
const params: ParamType = {
|
||||
field: 'hiiiii'
|
||||
};
|
||||
|
||||
this.uploader.addFiles(
|
||||
new FileList(),
|
||||
params,
|
||||
"/my/happy/endpoint"
|
||||
);
|
||||
}
|
||||
|
||||
testAddInitialFiles() {
|
||||
interface InitialFiles {
|
||||
myField: number;
|
||||
}
|
||||
|
||||
const initialFiles: InitialFiles[] = [{
|
||||
myField: 1324
|
||||
}];
|
||||
|
||||
this.uploader.addInitialFiles(initialFiles);
|
||||
}
|
||||
|
||||
testDrawThumbnail() {
|
||||
const promise: Promise<any> = this.uploader.drawThumbnail(
|
||||
1234,
|
||||
new HTMLElement(),
|
||||
1234565,
|
||||
false,
|
||||
(resizeInfo) => {
|
||||
return new Promise<File | Blob>(() => {
|
||||
return new Blob();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
testGetUploads() {
|
||||
interface ResponseType {
|
||||
hi: string;
|
||||
}
|
||||
const response: ResponseType | ResponseType[] = this.uploader.getUploads<ResponseType>({
|
||||
status: "proggresssssssesees"
|
||||
});
|
||||
}
|
||||
|
||||
testSetCustomHeaders() {
|
||||
interface CustomHeader {
|
||||
customField: number;
|
||||
}
|
||||
|
||||
this.uploader.setCustomHeaders<CustomHeader>({
|
||||
customField: 1234
|
||||
}, 1234);
|
||||
}
|
||||
|
||||
testSetDeleteCustomHeaders() {
|
||||
interface CustomHeader {
|
||||
customField: number;
|
||||
}
|
||||
|
||||
this.uploader.setDeleteFileCustomHeaders<CustomHeader>({
|
||||
customField: 1234
|
||||
}, 1234);
|
||||
}
|
||||
|
||||
testSetDeleteFileParams() {
|
||||
interface CustomParams {
|
||||
paramField: boolean;
|
||||
}
|
||||
this.uploader.setDeleteFileParams<CustomParams>({
|
||||
paramField: false
|
||||
}, 1234);
|
||||
}
|
||||
|
||||
testSetParams() {
|
||||
interface CustomParams {
|
||||
customParams: number;
|
||||
}
|
||||
|
||||
this.uploader.setParams<CustomParams>({
|
||||
customParams: 1234
|
||||
}, 1234);
|
||||
}
|
||||
|
||||
bulkTests() {
|
||||
this.uploader.cancel(1);
|
||||
this.uploader.cancelAll();
|
||||
this.uploader.clearStoredFiles();
|
||||
const shouldContinue: boolean = this.uploader.continueUpload(1234);
|
||||
this.uploader.deleteFile(1234);
|
||||
const elem: HTMLElement = this.uploader.getButton(1234);
|
||||
const fileOrBlob: File | Blob = this.uploader.getFile(1234);
|
||||
let num: number = this.uploader.getInProgress();
|
||||
let s: string = this.uploader.getName(1234);
|
||||
num = this.uploader.getParentId(1234);
|
||||
num = this.uploader.getRemainingAllowedItems();
|
||||
const resumables: qq.ResumableItem[] = this.uploader.getResumableFilesData();
|
||||
num = this.uploader.getSize(1234);
|
||||
s = this.uploader.getUuid(1234);
|
||||
this.uploader.log("why am i doing this?", "info");
|
||||
const b: boolean = this.uploader.pauseUpload(1234);
|
||||
this.uploader.reset();
|
||||
this.uploader.retry(1234);
|
||||
const blobPromise: Promise<Blob> = this.uploader.scaleImage(1234, {
|
||||
maxSize: 20,
|
||||
orient: false,
|
||||
type: "png",
|
||||
quality: 10,
|
||||
includeExif: false,
|
||||
});
|
||||
this.uploader.setEndpoint("/my/path/is/my/own", 1234);
|
||||
this.uploader.setEndpoint("/my/path/is/my/own", new HTMLElement());
|
||||
this.uploader.setDeleteFileEndpoint("/some/path", 1234);
|
||||
this.uploader.setDeleteFileEndpoint("/some/path", new HTMLElement());
|
||||
this.uploader.setItemLimit(1234);
|
||||
this.uploader.setForm(new HTMLFormElement());
|
||||
this.uploader.setForm("myFormElement");
|
||||
this.uploader.setName(1234, "myCustomName");
|
||||
this.uploader.setUuid(1234, "12341234");
|
||||
this.uploader.uploadStoredFiles();
|
||||
}
|
||||
|
||||
uiTests() {
|
||||
this.uploader.addExtraDropzone(new HTMLElement());
|
||||
let elem: HTMLElement = this.uploader.getDropTarget(1234);
|
||||
const n: number = this.uploader.getId(elem);
|
||||
elem = this.uploader.getItemByFileId(n);
|
||||
this.uploader.removeExtraDropzone(elem);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
function pasteTest() {
|
||||
const targetElement: HTMLElement = new HTMLElement();
|
||||
|
||||
const pasteOptions: qq.PasteOptions = {
|
||||
defaultName: "pasted_image",
|
||||
targetElement
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
paste: pasteOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
function requestTest() {
|
||||
interface CustomHeader {
|
||||
customHeader: string;
|
||||
}
|
||||
|
||||
interface CustomParam {
|
||||
customParam: boolean;
|
||||
}
|
||||
|
||||
const requestOptions: qq.RequestOptions<CustomHeader, CustomParam> = {
|
||||
customHeaders: {
|
||||
customHeader: "my custom header hehehehee"
|
||||
},
|
||||
endpoint: "/my/custom/endpoint",
|
||||
filenameParam: "newFilenameParam",
|
||||
forceMultipart: true,
|
||||
inputName: "filenameParamMapping",
|
||||
method: "POST",
|
||||
params: {
|
||||
customParam: false
|
||||
},
|
||||
paramsInBody: false,
|
||||
uuid: "asdf123456",
|
||||
totalFileSizeName: "totalFileSize"
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
request: requestOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
function resumeTest() {
|
||||
const resumeOptions: qq.ResumeOptions = {
|
||||
recordsExpireIn: 10,
|
||||
enabled: true,
|
||||
paramNames: {
|
||||
resuming: "ew you"
|
||||
}
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
resume: resumeOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
function retryTest() {
|
||||
|
||||
const retryOptions: qq.RetryOptions = {
|
||||
autoAttemptDelay: 1,
|
||||
enableAuto: true,
|
||||
maxAutoAttempts: 32,
|
||||
preventRetryResponseProperty: "preventRetry"
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
retry: retryOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
function scalingTest() {
|
||||
const scalingOptions: qq.ScalingOptions = {
|
||||
customResizer: (blob, height, image, sourceCanvas, targetCanvas, width) => {
|
||||
const promise = new Promise<File|Blob>(() => {
|
||||
return blob;
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
defaultQuality: 10,
|
||||
defaultType: "JPEG",
|
||||
failureText: "you have failed me for the last time",
|
||||
includeExif: true,
|
||||
orient: false,
|
||||
sendOriginal: true,
|
||||
sizes: [
|
||||
{
|
||||
maxSize: 10,
|
||||
name: "i am added to name",
|
||||
type: "mime type"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
scaling: scalingOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
function sessionTest() {
|
||||
interface CustomHeader {
|
||||
customHeader: string;
|
||||
}
|
||||
|
||||
interface CustomParam {
|
||||
customParam: boolean;
|
||||
}
|
||||
|
||||
const sessionOptions: qq.SessionOptions<CustomHeader, CustomParam> = {
|
||||
customHeaders: {
|
||||
customHeader: "customHeader"
|
||||
},
|
||||
endpoint: "/mysession/endpoint",
|
||||
params: {
|
||||
customParam: false
|
||||
},
|
||||
refreshOnReset: false
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
session: sessionOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
function textTest() {
|
||||
const textOptions: qq.TextOptions = {
|
||||
defaultResponseError: "you have failed me for the last time",
|
||||
fileInputTitle: "file input title",
|
||||
sizeSymbols: ['kb']
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
text: textOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
function validationTest() {
|
||||
|
||||
const validationOptions: qq.ValidationOptions = {
|
||||
acceptFiles: [new MimeType()],
|
||||
allowedExtensions: ['csv, xls'],
|
||||
itemLimit: 5,
|
||||
sizeLimit: 10000000,
|
||||
stopOnFirstInvalidFile: false,
|
||||
image: {
|
||||
maxHeight: 10,
|
||||
maxWidth: 10,
|
||||
minHeight: 1,
|
||||
minWidth: 1
|
||||
}
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
validation: validationOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
function workaroundsTest() {
|
||||
const workaroundOptions: qq.WorkaroundOptions = {
|
||||
iosEmptyVideos: false,
|
||||
ios8BrowserCrash: false,
|
||||
ios8SafariUploads: false
|
||||
};
|
||||
|
||||
const config: qq.BasicOptions = {
|
||||
workarounds: workaroundOptions
|
||||
};
|
||||
|
||||
const uploader = new qq.FineUploaderBasic(config);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/blobs.ts",
|
||||
"test/camera.ts",
|
||||
"test/chunking.ts",
|
||||
"test/core.ts",
|
||||
"test/cors.ts",
|
||||
"test/deleteFile.ts",
|
||||
"test/extraButtons.ts",
|
||||
"test/form.ts",
|
||||
"test/message.ts",
|
||||
"test/paste.ts",
|
||||
"test/resume.ts",
|
||||
"test/retry.ts",
|
||||
"test/request.ts",
|
||||
"test/scaling.ts",
|
||||
"test/session.ts",
|
||||
"test/text.ts",
|
||||
"test/validation.ts",
|
||||
"test/workarounds.ts",
|
||||
"test/method.ts",
|
||||
"test/callbacks.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -323,6 +323,12 @@
|
||||
"typingsPackageName": "antd",
|
||||
"sourceRepoURL": "https://github.com/ant-design/ant-design",
|
||||
"asOfVersion": "1.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "FineUploader",
|
||||
"typingsPackageName": "fine-uploader",
|
||||
"sourceRepoURL": "http://fineuploader.com/",
|
||||
"asOfVersion": "5.14.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user