Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit cc8658a

Browse files
committed
fix: TypeScript declaration for lib/core/s3; add retry option
1 parent 5be9ba1 commit cc8658a

File tree

2 files changed

+130
-52
lines changed

2 files changed

+130
-52
lines changed

client/typescript/fine-uploader.d.ts

+100-51
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,10 @@ declare module "fine-uploader/lib/core" {
909909
* RequestOptions
910910
*/
911911
request?: RequestOptions;
912+
/**
913+
* RetryOptions
914+
*/
915+
retry?: RetryOptions;
912916
/**
913917
* ScalingOptions
914918
*/
@@ -933,8 +937,6 @@ declare module "fine-uploader/lib/core" {
933937
* Core callback functions
934938
*/
935939
callbacks?: CoreEvents;
936-
937-
938940
}
939941

940942
/**
@@ -2700,6 +2702,7 @@ declare module "fine-uploader/lib/azure" {
27002702
UIDeleteFileOptions,
27012703
UIMessages,
27022704
UIPasteOptions,
2705+
UIRetryOptions,
27032706
UIScalingOptions,
27042707
UITextOptions
27052708
} from 'fine-uploader';
@@ -2709,6 +2712,7 @@ declare module "fine-uploader/lib/azure" {
27092712
ChunkingOptions,
27102713
CorsOptions,
27112714
RequestOptions,
2715+
RetryOptions,
27122716
CoreOptions,
27132717
ResumableFileObject,
27142718
PromiseOptions
@@ -3062,10 +3066,12 @@ declare module "fine-uploader/lib/azure" {
30623066
* RequestOptions
30633067
*/
30643068
request?: AzureRequestOptions;
3065-
3069+
/**
3070+
* Retry options
3071+
*/
3072+
retry?: UIRetryOptions & RetryOptions;
30663073
}
30673074

3068-
30693075
}
30703076

30713077
}
@@ -3079,6 +3085,7 @@ declare module "fine-uploader/lib/s3" {
30793085
UIDeleteFileOptions,
30803086
UIMessages,
30813087
UIPasteOptions,
3088+
UIRetryOptions,
30823089
UIScalingOptions,
30833090
UITextOptions
30843091
} from 'fine-uploader';
@@ -3091,14 +3098,14 @@ declare module "fine-uploader/lib/s3" {
30913098
CoreOptions,
30923099
ResumableFileObject,
30933100
CoreEvents,
3094-
PromiseOptions
3101+
PromiseOptions,
3102+
RetryOptions
30953103
} from 'fine-uploader/lib/core';
30963104

3097-
3105+
import { s3 as s3Core } from 'fine-uploader/lib/core/s3';
30983106

30993107
export namespace s3 {
31003108

3101-
31023109
export class FineUploader extends FineUploaderCore {
31033110

31043111
constructor(fineuploaderOptions?: S3UIOptions);
@@ -3175,6 +3182,90 @@ declare module "fine-uploader/lib/s3" {
31753182
setUploadSuccessParams(newParams: any, id?: number): void;
31763183
}
31773184

3185+
/**
3186+
* S3UIOptions
3187+
*/
3188+
export interface S3UIOptions extends UIOptions, S3CoreOptions {
3189+
/**
3190+
* failedUploadText options
3191+
*/
3192+
failedUploadTextDisplay?: S3FailedUploadTextDisplayOptions;
3193+
/**
3194+
* chunking options
3195+
*/
3196+
chunking?: S3ChunkingOptions;
3197+
/**
3198+
* cors options
3199+
*/
3200+
cors?: S3CorsOptions;
3201+
/**
3202+
* request options
3203+
*/
3204+
request?: S3RequestOptions;
3205+
/**
3206+
* deleteFile options
3207+
*/
3208+
deleteFile?: UIDeleteFileOptions;
3209+
/**
3210+
* messages
3211+
*/
3212+
messages?: UIMessages;
3213+
/**
3214+
* paste UI options
3215+
*/
3216+
paste?: UIPasteOptions;
3217+
/**
3218+
* Retry options
3219+
*/
3220+
retry?: UIRetryOptions & RetryOptions;
3221+
/**
3222+
* UI scaling options
3223+
*/
3224+
scaling?: UIScalingOptions;
3225+
/**
3226+
* UI text options
3227+
*/
3228+
text?: UITextOptions;
3229+
}
3230+
3231+
export const FineUploaderBasic: typeof s3Core.FineUploaderBasic;
3232+
export type S3ChunkingOptions = s3Core.S3ChunkingOptions;
3233+
export type S3CredentialsOptions = s3Core.S3CredentialsOptions;
3234+
export type S3CorsOptions = s3Core.S3CorsOptions;
3235+
export type S3iFrameSupportOptions = s3Core.S3iFrameSupportOptions;
3236+
export type BucketFunction = s3Core.BucketFunction;
3237+
export type HostFunction = s3Core.HostFunction;
3238+
export type KeyFunction = s3Core.KeyFunction;
3239+
export type S3ObjectPropertyOptions = s3Core.S3ObjectPropertyOptions;
3240+
export type S3RequestOptions = s3Core.S3RequestOptions;
3241+
export type S3CustomHeaderFunction = s3Core.S3CustomHeaderFunction;
3242+
export type S3SignatureOptions = s3Core.S3SignatureOptions;
3243+
export type S3UploadSuccessOptions = s3Core.S3UploadSuccessOptions;
3244+
export type S3CoreOptions = s3Core.S3CoreOptions;
3245+
export type S3FailedUploadTextDisplayOptions = s3Core.S3FailedUploadTextDisplayOptions;
3246+
export type OnCredentialsExpired = s3Core.OnCredentialsExpired;
3247+
export type S3Events = s3Core.S3Events;
3248+
export type S3ResumableFileObject = s3Core.S3ResumableFileObject;
3249+
3250+
}
3251+
3252+
}
3253+
3254+
declare module "fine-uploader/lib/core/s3" {
3255+
3256+
import {
3257+
FineUploaderBasic as FineUploaderBasicCore,
3258+
ChunkingOptions,
3259+
CorsOptions,
3260+
RequestOptions,
3261+
CoreOptions,
3262+
ResumableFileObject,
3263+
CoreEvents,
3264+
PromiseOptions
3265+
} from 'fine-uploader/lib/core';
3266+
3267+
export namespace s3 {
3268+
31783269
export class FineUploaderBasic extends FineUploaderBasicCore {
31793270

31803271
constructor(fineuploaderOptions?: S3CoreOptions);
@@ -3252,7 +3343,6 @@ declare module "fine-uploader/lib/s3" {
32523343

32533344
}
32543345

3255-
32563346
/**
32573347
* S3CredentialsOptions
32583348
*/
@@ -3583,48 +3673,6 @@ declare module "fine-uploader/lib/s3" {
35833673
onCredentialsExpired?: OnCredentialsExpired;
35843674
}
35853675

3586-
/**
3587-
* S3UIOptions
3588-
*/
3589-
export interface S3UIOptions extends UIOptions, S3CoreOptions {
3590-
/**
3591-
* failedUploadText options
3592-
*/
3593-
failedUploadTextDisplay?: S3FailedUploadTextDisplayOptions;
3594-
/**
3595-
* chunking options
3596-
*/
3597-
chunking?: S3ChunkingOptions;
3598-
/**
3599-
* cors options
3600-
*/
3601-
cors?: S3CorsOptions;
3602-
/**
3603-
* request options
3604-
*/
3605-
request?: S3RequestOptions;
3606-
/**
3607-
* deleteFile options
3608-
*/
3609-
deleteFile?: UIDeleteFileOptions;
3610-
/**
3611-
* messages
3612-
*/
3613-
messages?: UIMessages;
3614-
/**
3615-
* paste UI options
3616-
*/
3617-
paste?: UIPasteOptions;
3618-
/**
3619-
* UI scaling options
3620-
*/
3621-
scaling?: UIScalingOptions;
3622-
/**
3623-
* UI text options
3624-
*/
3625-
text?: UITextOptions;
3626-
}
3627-
36283676
/**
36293677
* Resumable file object type for S3
36303678
*/
@@ -3634,6 +3682,7 @@ declare module "fine-uploader/lib/s3" {
36343682
*/
36353683
key?: string;
36363684
}
3685+
36373686
}
36383687

3639-
}
3688+
}

client/typescript/fine-uploader.test.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { FineUploader, UIOptions } from 'fine-uploader';
22
import { s3 } from 'fine-uploader/lib/s3';
33
import { azure } from 'fine-uploader/lib/azure';
44
import { PromiseOptions } from 'fine-uploader/lib/core';
5+
import { s3 as s3Core } from 'fine-uploader/lib/core/s3';
56

67
/**
78
* Prepare/set options for the core + UI FineUploader
@@ -59,6 +60,34 @@ let s3UIOptions: s3.S3UIOptions = {
5960
let s3Uploader = new s3.FineUploader(s3UIOptions);
6061

6162

63+
/**
64+
* Prepare/set options for the core Amazon S3 FineUploaderBasic
65+
*/
66+
let s3CoreOptions: s3Core.S3CoreOptions = {
67+
debug: true,
68+
request: {
69+
endpoint: '{ YOUR_BUCKET_NAME }.s3.amazonaws.com',
70+
accessKey: '{ YOUR_ACCESS_KEY }'
71+
},
72+
signature: {
73+
endpoint: '/s3/signature'
74+
},
75+
uploadSuccess: {
76+
endpoint: '/s3/success'
77+
},
78+
iframeSupport: {
79+
localBlankPagePath: '/success.html'
80+
},
81+
retry: {
82+
enableAuto: true // defaults to false
83+
},
84+
deleteFile: {
85+
enabled: true,
86+
endpoint: '/s3handler'
87+
}
88+
}
89+
let s3CoreUploader = new s3Core.FineUploaderBasic(s3CoreOptions);
90+
6291

6392
/**
6493
* Prepare/set options for the Amazon S3 FineUploader
@@ -102,4 +131,4 @@ promise.then(() => {
102131
});
103132
promise.done(() => {
104133
//promise is fulfilled whether successful or not, do something here
105-
});
134+
});

0 commit comments

Comments
 (0)