This repository has been archived by the owner on Nov 20, 2018. It is now read-only.
/
fine-uploader.d.ts
3639 lines (3360 loc) · 123 KB
/
fine-uploader.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for FineUploader 5.x.x
// Project: http://fineuploader.com/
// Definitions by: Sukhdeep Singh <https://github.com/SinghSukhdeep>
declare module "fine-uploader/lib/core" {
export class FineUploaderBasic {
/**
* The FineUploader Core only constructor
*/
constructor(fineuploaderOptions?: CoreOptions);
/**
* FineUploader's Promise implementation
*/
Promise(): void;
/**
* Submit one or more files to the uploader
*
* @param any[] files : An array of `File`s, `<input>`s, `Blob`s, `BlobWrapper` objects, `<canvas>`es, or `CanvasWrapper` objects. You may also pass in a `FileList`.
* @param any params : A set of parameters to send with the file to be added
* @param string endpoint : The endpoint to send this file to
*/
addFiles(files: File[]
| HTMLInputElement[]
| Blob[]
| BlobWrapper
| HTMLCanvasElement[]
| CanvasWrapper
| FileList, params?: any, endpoint?: string): void;
/**
* Submit one or more canned/initial files to the uploader
*
* @param any[] initialFiles : An array of objects that describe files already on the server
*/
addInitialFiles(initialFiles: any[]): void;
/**
* Cancel the queued or currently uploading item which corresponds to the id
*
* @param number id : The file's id
*/
cancel(id: number): void;
/**
* Cancels all queued or currently uploading items
*/
cancelAll(): void;
/**
* Clears the internal list of stored items. Only applies when autoUpload is false
*/
clearStoredFiles(): void;
/**
* Attempts to continue a paused upload
*
* @param number id : A file id
* @returns boolean : `true` if attempt was successful.
*/
continueUpload(id: number): boolean;
/**
* Send a delete request to the server for the corresponding file id
*
* @param number id : The file's id
*/
deleteFile(id: number): void;
/**
* Draws a thumbnail
*
* @param number id : The id of the image file
* @param HTMLElement targetContainer : The element where the image preview will be drawn. Must be either an <img> or <canvas> element
* @param number maxSize : The maximum dimensions (for width and height) you will allow this image to scale to
* @param boolean fromServer : true if the image data will come as a response from the server rather than be generated client-side
* @param CustomResizerCallBack customResizer : 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.
* @returns Promise: Fulfilled by passing the container back into the success callback after the thumbnail has been rendered.
* If the thumbnail cannot be rendered, failure callbacks will be invoked instead, passing an object with `container` and `error` properties.
*/
drawThumbnail(id: number, targetContainer: HTMLElement, maxSize?: number, fromServer?: boolean, customResizer?: CustomResizerCallBack): PromiseOptions;
/**
* Returns the button container element associated with a file
*
* @param number id : The file id
* @returns HTMLElement : The button container element associated with a file, or `undefined` if the file was not submitted via a Fine Uploader controlled upload button.
*/
getButton(id: number): HTMLElement;
/**
* Returns the file identified by the id. File API browsers only
*
* @param number id : The file id
* @returns File | Blob : A `File` or `Blob` object
*/
getFile(id: number): File | Blob;
/**
* Returns the endpoint associated with a particular file, or the current catch-all endpoint for all files (if no ID is specified).
*
* @param number id : The ID of the associated file
* @return string | string[] : endpoint associated with a particular file, or the current catch-all endpoint for all files (if no ID is specified).
*/
getEndpoint(id?: number): string | string[];
/**
* Returns the number of items that are either currently uploading or waiting for an available connection (`qq.status.QUEUED`).
*
* If called inside of a cancel event handler, then this method will return a value that includes the upload associated with the cancel event handler.
* This is because the upload will not be canceled until the event handler returns.
*
* @returns number : The number of items that are currently uploading or queued
*/
getInProgress(): number;
/**
* Returns the name of the file with the associated id
*
* @param number id : The file id
* @returns string : Returns the name of the file identified by the id.
*/
getName(id: number): string;
/**
* Get the number of items that have been successfully uploaded and have not been deleted
*
* @returns number : The number of items that have been successfully uploaded and not deleted
*/
getNetUploads(): number;
/**
* Get the ID of the parent file for this scaled file
*
* @param number scaledFileId : The ID of a scaled image file
* @returns number : Returns the ID of the scaled image's parent file. `null` if this is not a scaled image or a parent cannot be located
*/
getParentId(scaledFileId: number): number;
/**
* Returns the number of remaining allowed items that may be submitted for upload based on `validation.itemLimit`.
*/
getRemainingAllowedItems(): number;
/**
* Returns an array of potentially resumable items
*
* @returns ResumableFileObject[] : An array of resumable items
*/
getResumableFilesData(): ResumableFileObject[] | ResumableFileObject;
/**
* Returns the size of the item with the associated id
*
* @param number id : The file id
* @returns number : The size of the file with the corresponding id
*/
getSize(id: number): number;
/**
* Return information about all the items that have been submitted to the uploader
*
* @param UploadFilter filter : An object which indicates which keys and values must be present in an upload to be returned
* @return FoundUploadItems | FoundUploadItems [] : A list of items or a single item that has been filtered/found.
* This returns an array only when there is a potential for the operation to return more than one file in the result set.
* This excludes queries for a specific, single ID or UUID. All other queries will return an array
*/
getUploads(filter?: UploadFilter): FoundUploadItems | FoundUploadItems[];
/**
* Returns the UUID of the item with the associated id
*
* @param number id : The file id
* @returns string : A level 4 UUID which identifies the corresponding file
*/
getUuid(id: number): string;
/**
* Returns true if the file can be auto-resumed, false otherwise.
*
* @param number id : The file id
* @returns boolean : True if the file can be resumed and has a resume record, false otherwise
*/
isResumable(id: number): boolean;
/**
* Output a message to the console, if possible
*
* @param string message : The message to print
* @param string level : The level to output the message at
*/
log(message: string, level?: string): void;
/**
* Attempts to pause an in-progress upload
*
* @param number id : The file id
* @returns boolean : `true` if the attempt was successful. `false` otherwise
*/
pauseUpload(id: number): boolean;
/**
* Remove internal reference to the associated Blob/File object.
*
* For Blobs that are created via JavaScript in the browser, this will free up all consumed memory.
*/
removeFileRef(id: number): void;
/**
* Reset Fine Uploader
*/
reset(): void;
/**
* Attempt to upload a specific item again
*
* @param number id : The file id
*/
retry(id: number): void;
/**
* Generates a scaled version of a submitted image file
*
* @param number id : The id of the image file
* @param ScaleImageOptions option : Information about the scaled image to generate
* @returns PromiseOptions : Fulfilled by passing the scaled image as a `Blob` back into the success callback after the original image has been scaled.
* If the scaled image cannot be generated, the failure callback will be invoked instead
*/
scaleImage(id: number, options: ScaleImageOptions): PromiseOptions;
/**
* Set custom headers for an upload request. Pass in a file id to make the headers specific to that file
*
* @param any customHeaders : The custom headers to include in the upload request. Fine Uploader may also send some other required headers
* @param number id : The file id
*/
setCustomHeaders(customHeaders: any, id?: number): void;
/**
* Set custom resume data for a potentially resumable file.
* This data will be stored with the file's resume record and will be accessible in the `onResume` event handler and via the `getResumableFilesData` API method.
*
* @param number id : The file id
* @param Object customResumeData : The custom resume data to store with the file's resume record
*/
setCustomResumeData(id: number, customResumeData: Object): void;
/**
* Modify the location where upload requests should be directed. Pass in a file id to change the endpoint for that specific item
*
* @param string path : A valid URI where upload requests will be sent
* @param number | HTMLElement identifier : An integer or HTMLElement corresponding to a file
*/
setEndpoint(path: string, identifier?: number | HTMLElement): void;
/**
* Set custom headers for a delete file request. Pass in a file id to make the headers specific to that file
*
* @param any customHeaders : The custom headers to include in the upload request. Fine Uploader may also send some other required headers
* @param number id : The file id
*/
setDeleteFileCustomHeaders(customHeaders: any, id?: number): void;
/**
* Modify the location where delete requests should be directed. Pass in a file id to change the endpoint for that specific item
*
* @param string path : A valid URI where delete requests will be sent
* @param number | HTMLElement identifier : An integer or HTMLElement corresponding to a file
*/
setDeleteFileEndpoint(path: string, identifier?: number | HTMLElement): void;
/**
* Set the parameters for a delete request. Pass in a file id to make the parameters specific to that file
*
* @param any params : The parameters to include in the delete request
* @param number id : The file id
*/
setDeleteFileParams(params: any, id?: number): void;
/**
* Change the `validation.itemLimit` option set during construction/initialization
*
* @param number newItemLimit : The new file count limit
*/
setItemLimit(newItemLimit: number): void;
/**
* Bind a `<form>` to Fine Uploader dynamically
*
* @param HTMLFormElement | string formElementOrId : A form element or a form element's ID
*/
setForm(formElementOrId: HTMLFormElement | string): void;
/**
* Change the name of a file
*
* @param number id: The file id
* @param string name : The new file name
*/
setName(id: number, name: string): void;
/**
* Set the parameters for an upload request. Pass in a file id to make the parameters specific to that file
*
* @param any params : The parameters to include in the upload request
* @param number id : The file id
*/
setParams(params: any, id?: number): void;
/**
* Modify the status of an file.
* The status values correspond to those found in the qq.status object.
* Currently, the following status values may be set via this method:
* - qq.status.DELETED
* - qq.status.DELETE_FAILED
*
* @param number id : The file id
* @param string newStatus : The new qq.status value.
*/
setStatus(id: number, newStatus: string): void;
/**
* Change the UUID of a file
*
* @param number id : The file id
* @param string uuid : The new file UUID
*/
setUuid(id: number, uuid: string): void;
/**
* Begin uploading all queued items. Throws a `NoFilesError` if there are no items to upload
*/
uploadStoredFiles(): void;
/* ====================================== UTILITY METHODS ======================================= */
/**
* Returns an array of all immediate children of this element.
*
* @param HTMLElement element : An HTMLElement or an already wrapped qq object
* @returns HTMLElement[] : An array of HTMLElements who are children of the `element` parameter
*/
children(element: HTMLElement): HTMLElement[];
/**
* Returns true if the element contains the passed element.
*
* @param HTMLElement element : An HTMLElement or an already wrapped qq object
* @returns boolean : The result of the contains test
*/
contains(element: HTMLElement): boolean;
/**
* Returns `true` if the attribute exists on the element and the value of the attribute is not 'false' case-insensitive.
*
* @param string attributeName : An attribute to test for
* @returns boolean : The result of the `hasAttribute` test
*/
hasAttribute(attributeName: string): boolean;
/**
* Clears all text for this element
*/
clearText(): void;
/**
* Inserts the element directly before the passed element in the DOM.
*
* @param HTMLElement element : the `element` before which an element has to be inserted
*/
insertBefore(element: HTMLElement): void;
/**
* Removes the element from the DOM.
*/
remove(): void;
/**
* Sets the inner text for this element.
*
* @param string text : The text to set
*/
setText(text: string): void;
/**
* Add a class to this element.
*
* @param string className : The name of the class to add to the element
*/
addClass(className: string): void;
/**
* Add CSS style(s) to this element.
*
* @param Object styles : An object with styles to apply to this element
* @returns Object : Returns the current context to allow method chaining
*/
css(styles: any): this;
/**
* Returns an array of all descendants of this element that contain a specific class name.
*
* @param string className : The name of the class to look for in each element
* @returns HTMLElement[] : An array of `HTMLElements
*/
getByClass(className: string): HTMLElement[];
/**
* Returns `true` if the element has the class name
*
* @param string className : The name of the class to look for in each element
* @returns boolean : Result of the `hasClass` test
*/
hasClass(className: string): boolean;
/**
* Hide this element.
*
* @returns Object : Returns the current context to allow method chaining
*/
hide(): this;
/**
* Remove the provided class from the element.
*
* @param string className : The name of the class to look for in each element
* @returns Object : Returns the current context to allow method chaining
*/
removeClass(className: string): this;
/**
* Attach an event handler to this element for a specific DOM event.
*
* @param string event : A valid `DOM Event`
* @param function handler : A function that will be invoked whenever the respective event occurs
* @returns function : Call this function to detach the event
*/
attach(event: string, handler: () => any | void): () => any | void;
/**
* Detach an already attached event handler from this element for a specific DOM event
*
* @param string event : A valid `DOM Event`
* @param function originalHandler : A function that will be detached from this event
* @returns Object : Call this function to detach the event
*/
detach(event: string, originalHandler: () => any | void): this;
/**
* Shim for `Function.prototype.bind`
*
* Creates a new function that, when called, has its `this` keyword set to the provided context.
* Pass comma-separated values after the `context` parameter for all arguments to be passed into the new function (when invoked).
* You can still pass in additional arguments during invocation.
*
* @param function oldFunc : The function that will be bound to
* @param Object context : The context the function will assume
* @returns function : A new function, same as the old one, but bound to the passed in `context`
*/
bind(oldFunc: () => any | void, context: any): () => any;
/**
* Iterates through a collection, passing the key and value into the provided callback. `return false;` to stop iteration.
*
* @param Array or Object :
* @param function callback : A function that will be called for each item returned by looping through the iterable. This function takes an index and an item.
*/
each(iterable: any[] | any, callback: (index: number, item: any) => any | void): () => any | void;
/**
* Shallowly copies the parameters of secondobj to firstobj. if extendnested is true then a deep-copy is performed.
*
* @param Object firstObj : The object to copy parameters to
* @param Object secondObj : The object to copy parameters from
* @param boolean extendNested : If `true` then a deep-copy is performed, else a shallow copy
* @returns Object : The new object created by the extension
*/
extend(firstObj: any, secondObj: any, extendNested?: boolean): any;
/**
* Returns a string, swapping argument values with the associated occurrence of `{}` in the passed string
*
* @param string message : the string to be formatted
* @returns string : the formatted string
*/
format(message: string): string;
/**
* Return the extension for the filename, if any
*
* @param string filename : The file's name to rip the extension off of
* @returns string : The extension name
*/
getExtension(filename: string): string;
/**
* Returns a version4 uuid
*
* @returns string : A version 4 unique identifier
*/
getUniqueId(): string;
/**
* Returns the index of `item` in the `Array` starting the search from `startingindex`
*
* @param any[] array : the array to search in
* @param Object item : the item to search for
* @param number startingIndex : the index to search from
* @returns number : The index of `item` in the array
*/
indexOf(array: any[], item: any, startingIndex?: number): number;
/**
* Check if the parameter is function
*
* @param Object func : The object to test
* @returns boolean : Whether the parameter is a function or not
*/
isFunction(func: any): boolean;
/**
* Check if the parameter is object
*
* @param Object obj : The thing to test
* @returns boolean : Whether the parameter is a object or not
*/
isObject(obj: any): boolean;
/**
* Check if the parameter is string
*
* @param Object str : The object to test
* @returns boolean : Whether the parameter is a string or not
*/
isString(str: any): boolean;
/**
* Log a message to the console. no-op if console logging is not supported. shim for `console.log`
*
* @param string logMessage : The message to log
* @param string logLevel : The logging level, such as 'warn' and 'info'. If `null`, then 'info' is assumed
*/
log(logMessage: string, logLevel?: string): void;
/**
* Prevent the browser's default action on an event
*
* @param string event : The name of the default event to prevent
*/
preventDefault(event: string): void;
/**
* Creates and returns a new <div> element
*
* @param string str : Valid HTML that can be parsed by a browser.
* @returns HTMLElement : An newly created `HTMLElement` from the input
*/
toElement(str: string): HTMLElement;
/**
* Removes whitespace from the ends of a string. Shim for `String.prototype.trim`
*
* @param string str : The string to remove whitespace from
* @returns string : The new string sans whitespace
*/
trimstr(str: string): string;
/* ====================================== END - UTILITY METHODS ================================= */
}
/* ====================================== Misc Options and Wrappers ==================================== */
/**
* Callback type for `customResizer` parameter
*/
export 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): PromiseOptions;
}
/**
* The FineUploader namespace contains all the methods, options, events and types
/* ========================================================== CORE & UI ===================================================================== */
/**
* type for `resizeInfo` object
*/
export 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;
}
/**
* type for getUploads method's filter parameter
*/
export 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
*/
export interface FoundUploadItems extends UploadFilter {
/**
* the name of the file
*/
name?: string;
/**
* the size of the file
*/
size?: string;
}
/**
* ScaleImageOptions
*/
export 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;
}
export interface PromiseOptions {
/**
* Register callbacks from success and failure.
*
* The promise instance that then is called on will pass any values into the provided callbacks.
* If success or failure have already occurred before these callbacks have been registered, then they will be called immediately after this call has been executed.
* Each subsequent call to then registers an additional set of callbacks.
*
* @param Function successCallback : The function to call when the promise is successfully fulfilled
* @param Function failureCallback : The function to call when the promise is unsuccessfully fulfilled
* @return PromiseOptions : An instance of a promise
*/
then(successCallback: Function, failureCallback: Function): PromiseOptions;
/**
* Register callbacks for success or failure.
*
* Invoked when the promise is fulfilled regardless of the result.
* The promise instance that done is called on will pass any values into the provided callback.
* Each call to done registers an additional set of callbacks
*
* @param Function callback : The function to call when the promise is fulfilled, successful or not.
* @return PromiseOptions : An instance of a promise
*/
done(callback: Function): PromiseOptions;
/**
* Call this on a promise to indicate success.
* The parameter values will depend on the situation.
*
* @param Object param : The value to pass to the promise's success handler.
* @return PromiseOptions : An instance of a promise
*/
success(param: any): PromiseOptions;
/**
* Call this on a promise to indicate failure.
* The parameter values will depend on the situation.
*
* @param Object param : The value to pass to the promise's failure handler.
* @return PromiseOptions : An instance of a promise
*/
failure(param: any): PromiseOptions;
}
/**
* A BlobWrapper object type
*/
export interface BlobWrapper {
/**
* the bytes of the `Blob` object being uploaded
*/
blob?: Blob;
/**
* the name of the `Blob`
*/
name?: string;
}
/**
* A CanvasWrapper Object type
*/
export interface CanvasWrapper {
/**
* the `<canvas>` 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 `<canvas>`
*/
type?: MimeType;
}
/**
* Resumable file object type
*/
export interface ResumableFileObject {
/**
* an object containing any custom resume data for the file
*/
customResumeData?: any;
/**
* filename
*/
name?: string;
/**
* number of bytes to be uploaded
*/
remaining?: number;
/**
* the unique id
*/
uuid?: number;
/**
* total file size in bytes
*/
size?: number;
}
/* ====================================== Core Options ==================================== */
/**
* Contains Core options
*/
export 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 `<button>`
*
* @default `null`
*/
button?: HTMLElement;
/**
* This will result in log messages being written to the `window.console` object
*
* @default `false`
*/
debug?: boolean;
/**
* When true the cancel link does not appear next to files when the form uploader is used
*
* @default `false`
*/
disableCancelForFormUploads?: boolean;
/**
* Provide a function to control the display of file names.
*
* The raw file name is passed into the function when it is invoked. Your function may return a modified file name.
*
* Note that this does not affect the actual file name, only the displayed file name
*/
formatFileName?: FormatFileNameFuncton;
/**
* Maximum allowable concurrent requests
*
* @default `3`
*/
maxConnections?: number;
/**
* When false this will prevent the user from simultaneously selecting or dropping more than one item
*
* @default `true`
*/
multiple?: boolean;
/**
* When true Fine Uploader will ensure a modal confirmation dialog appears whenever a user tries to navigate away from the page with uploads in progress
*
* @default `true`
*/
warnBeforeUnload?: boolean;
/**
* blobs options
*/
blobs?: BlobsOptions;
/**
* camera options
*/
camera?: CameraOptions;
/**
* ChunkingOptions
*/
chunking?: ChunkingOptions;
/**
* CorsOptions
*/
cors?: CorsOptions;
/**
* DeleteFileOptions
*/
deleteFile?: DeleteFileOptions;
/**
* ExtraButtonsOptions
*/
extraButtons?: ExtraButtonsOptions[];
/**
* FormOptions
*/
form?: FormOptions;
/**
* Messages
*/
messages?: Messages;
/**
* PasteOptions
*/
paste?: PasteOptions;
/**
* ResumeOptions
*/
resume?: ResumeOptions;
/**
* RequestOptions
*/
request?: RequestOptions;
/**
* ScalingOptions
*/
scaling?: ScalingOptions;
/**
* SessionOptions
*/
session?: SessionOptions;
/**
* TextOptions
*/
text?: TextOptions;
/**
* ValidationOptions
*/
validation?: ValidationOptions;
/**
* WorkArounds
*/
workarounds?: WorkArounds;
/**
* Core callback functions
*/
callbacks?: CoreEvents;
}
/**
* formatFileName function type
*/
export interface FormatFileNameFuncton {
(fileOrBlobName: string): string
}
/**
* BlobsOptions
*/
export interface BlobsOptions {
/**
* The default name to be used for nameless `Blob`s
*
* @default `Misc data`
*/
defaultName?: string;
}
/**
* CameraOptions
*/
export 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
*/
export interface ConcurrentOptions {
/**
* Allow multiple chunks to be uploaded simultaneously per file
*
* @default `false`
*/
enabled?: boolean;
}
/**
* ChunkingOptions
*/
export interface ChunkingOptions {
/**
* concurrent Chunking options
*/