Skip to content

add withCredentials option #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Dropzone/components/dropzone/Dropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
autoClean,
//uploading
uploadConfig,
withCredentials,
fakeUpload,
groupUpload,
onUploadStart,
Expand Down Expand Up @@ -357,6 +358,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
}
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.withCredentials = withCredentials;
xhr.upload.onprogress = (e) => {
arrOfExtFilesInstances.forEach((el) => {
el.progress = (e.loaded / e.total) * 100;
Expand Down
40 changes: 24 additions & 16 deletions src/Dropzone/components/dropzone/DropzoneProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
* Probably one of the most important methods (callbacks).
* `onChange()` returns as first parameter an array of `ExtFile` objects,
* with at least the following structure:
*
*
* ```jsx
* export type ExtFile =
* {
Expand All @@ -21,7 +21,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
* uploadStatus?: undefined | "uploading", "success", "error";
* }
* ```
* This event is triggered when upload starts and when upload
* This event is triggered when upload starts and when upload
* finishes for each file in order to update the props on each ExtFile
*/
onChange?: (files: ExtFile[]) => void;
Expand All @@ -35,10 +35,10 @@ export interface DropzoneFullProps extends OverridableComponentProps {
/**
* The default implementation of accept
* checks the file's mime type or extension
* against this list. This is a comma-separated
* list of one or more file types, or unique file type specifiers,
* against this list. This is a comma-separated
* list of one or more file types, or unique file type specifiers,
* describing which file types to allow.
* E.g.:
* E.g.:
* ```js
* acccept="image/*, application/pdf, .psd"
* ```
Expand Down Expand Up @@ -70,12 +70,12 @@ export interface DropzoneFullProps extends OverridableComponentProps {
*/
onClean?: Function;
/**
* If true, the component will automatically remove non valid files when user
* If true, the component will automatically remove non valid files when user
* drops files or selects them from file dialog. This flag will only work if validation is active.
*/
autoClean?: boolean;
/**
* When given, "clean" button will be visible and
* When given, "clean" button will be visible and
* every time user clicks the buttom it will trigger the default "clean operation":
* Remove non valid files.
* This flag will only work if validation is active.
Expand All @@ -90,6 +90,13 @@ export interface DropzoneFullProps extends OverridableComponentProps {
* and uploadOnDrop prop flag will not work.
*/
uploadConfig?: UploadConfig;

/**
* Will be set on the XHRequest.withCredentials property
* Default is false
*/
withCredentials?: boolean;

/**
* If set, the component will simulate the upload operation by randomly
setting the upload status and message on each uploadable{" "}
Expand All @@ -113,7 +120,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
onUploadFinish?: (uploadedFiles: ExtFile[]) => void;


/////////////// STYLING ///////////
/////////////// STYLING ///////////
//borderRadius?: string | number;
/**
* The background color for dropzone container.
Expand All @@ -124,16 +131,16 @@ export interface DropzoneFullProps extends OverridableComponentProps {
* The min height of the component.
* If the value is given in number format, "px" will be assumed
* @default "180px"
*
* examples:
*
* examples:
* "50vh"
* "20%"
* "40em"
* "1rem"
*/
minHeight?: string | number;

///////////////// LABEL ///////////////
///////////////// LABEL ///////////////
/**
* The label to place when no files were selected
*/
Expand Down Expand Up @@ -203,7 +210,7 @@ export interface DropzoneFullProps extends OverridableComponentProps {
*/
disabled?: boolean;
//CLICKABLE
/**
/**
* If false, the component will not be clickable. So, file dialog will not be opened.
* @default true
*/
Expand Down Expand Up @@ -237,15 +244,15 @@ export type FooterConfig = {
*/
allowedTypesLabel?: boolean;
/**
*
*
*/
uploadProgressMessage?: boolean;
/**
*
*
*/
uploadResultMessage?: boolean;
/**
*
*
*/
noMissingFilesLabel?: boolean;

Expand Down Expand Up @@ -300,6 +307,7 @@ export const defaultDrozoneProps: DropzoneProps =
disabled: false,
dropOnLayer: true,
uploadConfig: {},
withCredentials: false,
actionButtons: {},
header: true,
footer: true,
Expand All @@ -310,7 +318,7 @@ export const defaultDrozoneProps: DropzoneProps =
export const DEFAULT_BORDER_RADIUS = "8px";


/*
/*
export interface AdvancedConfigItem {
style?: React.CSSProperties;
className?: string;
Expand Down
Loading