Skip to content

Commit f1fe235

Browse files
committed
add withCredentials option
1 parent 9c0550e commit f1fe235

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Dropzone/components/dropzone/Dropzone.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
9595
autoClean,
9696
//uploading
9797
uploadConfig,
98+
withCredentials,
9899
fakeUpload,
99100
groupUpload,
100101
onUploadStart,
@@ -357,6 +358,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
357358
}
358359
return new Promise((resolve, reject) => {
359360
let xhr = new XMLHttpRequest();
361+
xhr.withCredentials = withCredentials;
360362
xhr.upload.onprogress = (e) => {
361363
arrOfExtFilesInstances.forEach((el) => {
362364
el.progress = (e.loaded / e.total) * 100;

src/Dropzone/components/dropzone/DropzoneProps.ts

+24-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
99
* Probably one of the most important methods (callbacks).
1010
* `onChange()` returns as first parameter an array of `ExtFile` objects,
1111
* with at least the following structure:
12-
*
12+
*
1313
* ```jsx
1414
* export type ExtFile =
1515
* {
@@ -21,7 +21,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
2121
* uploadStatus?: undefined | "uploading", "success", "error";
2222
* }
2323
* ```
24-
* This event is triggered when upload starts and when upload
24+
* This event is triggered when upload starts and when upload
2525
* finishes for each file in order to update the props on each ExtFile
2626
*/
2727
onChange?: (files: ExtFile[]) => void;
@@ -35,10 +35,10 @@ export interface DropzoneFullProps extends OverridableComponentProps {
3535
/**
3636
* The default implementation of accept
3737
* checks the file's mime type or extension
38-
* against this list. This is a comma-separated
39-
* list of one or more file types, or unique file type specifiers,
38+
* against this list. This is a comma-separated
39+
* list of one or more file types, or unique file type specifiers,
4040
* describing which file types to allow.
41-
* E.g.:
41+
* E.g.:
4242
* ```js
4343
* acccept="image/*, application/pdf, .psd"
4444
* ```
@@ -70,12 +70,12 @@ export interface DropzoneFullProps extends OverridableComponentProps {
7070
*/
7171
onClean?: Function;
7272
/**
73-
* If true, the component will automatically remove non valid files when user
73+
* If true, the component will automatically remove non valid files when user
7474
* drops files or selects them from file dialog. This flag will only work if validation is active.
7575
*/
7676
autoClean?: boolean;
7777
/**
78-
* When given, "clean" button will be visible and
78+
* When given, "clean" button will be visible and
7979
* every time user clicks the buttom it will trigger the default "clean operation":
8080
* Remove non valid files.
8181
* This flag will only work if validation is active.
@@ -90,6 +90,13 @@ export interface DropzoneFullProps extends OverridableComponentProps {
9090
* and uploadOnDrop prop flag will not work.
9191
*/
9292
uploadConfig?: UploadConfig;
93+
94+
/**
95+
* Will be set on the XHRequest.withCredentials property
96+
* Default is false
97+
*/
98+
withCredentials?: boolean;
99+
93100
/**
94101
* If set, the component will simulate the upload operation by randomly
95102
setting the upload status and message on each uploadable{" "}
@@ -113,7 +120,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
113120
onUploadFinish?: (uploadedFiles: ExtFile[]) => void;
114121

115122

116-
/////////////// STYLING ///////////
123+
/////////////// STYLING ///////////
117124
//borderRadius?: string | number;
118125
/**
119126
* The background color for dropzone container.
@@ -124,16 +131,16 @@ export interface DropzoneFullProps extends OverridableComponentProps {
124131
* The min height of the component.
125132
* If the value is given in number format, "px" will be assumed
126133
* @default "180px"
127-
*
128-
* examples:
134+
*
135+
* examples:
129136
* "50vh"
130137
* "20%"
131138
* "40em"
132139
* "1rem"
133140
*/
134141
minHeight?: string | number;
135142

136-
///////////////// LABEL ///////////////
143+
///////////////// LABEL ///////////////
137144
/**
138145
* The label to place when no files were selected
139146
*/
@@ -203,7 +210,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
203210
*/
204211
disabled?: boolean;
205212
//CLICKABLE
206-
/**
213+
/**
207214
* If false, the component will not be clickable. So, file dialog will not be opened.
208215
* @default true
209216
*/
@@ -237,15 +244,15 @@ export type FooterConfig = {
237244
*/
238245
allowedTypesLabel?: boolean;
239246
/**
240-
*
247+
*
241248
*/
242249
uploadProgressMessage?: boolean;
243250
/**
244-
*
251+
*
245252
*/
246253
uploadResultMessage?: boolean;
247254
/**
248-
*
255+
*
249256
*/
250257
noMissingFilesLabel?: boolean;
251258

@@ -300,6 +307,7 @@ export const defaultDrozoneProps: DropzoneProps =
300307
disabled: false,
301308
dropOnLayer: true,
302309
uploadConfig: {},
310+
withCredentials: false,
303311
actionButtons: {},
304312
header: true,
305313
footer: true,
@@ -310,7 +318,7 @@ export const defaultDrozoneProps: DropzoneProps =
310318
export const DEFAULT_BORDER_RADIUS = "8px";
311319

312320

313-
/*
321+
/*
314322
export interface AdvancedConfigItem {
315323
style?: React.CSSProperties;
316324
className?: string;

0 commit comments

Comments
 (0)