Adding withCredentials to uploader options
This commit is contained in:
@@ -39,6 +39,7 @@ export interface FileUploaderOptions {
|
|||||||
parametersBeforeFiles?: boolean;
|
parametersBeforeFiles?: boolean;
|
||||||
formatDataFunction?: Function;
|
formatDataFunction?: Function;
|
||||||
formatDataFunctionIsAsync?: boolean;
|
formatDataFunctionIsAsync?: boolean;
|
||||||
|
withCredentials?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FileUploader {
|
export class FileUploader {
|
||||||
@@ -51,6 +52,7 @@ export class FileUploader {
|
|||||||
public autoUpload: any;
|
public autoUpload: any;
|
||||||
public authTokenHeader: string;
|
public authTokenHeader: string;
|
||||||
public response: EventEmitter<any>;
|
public response: EventEmitter<any>;
|
||||||
|
public withCredentials: boolean = null;
|
||||||
|
|
||||||
public options: FileUploaderOptions = {
|
public options: FileUploaderOptions = {
|
||||||
autoUpload: false,
|
autoUpload: false,
|
||||||
@@ -75,6 +77,8 @@ export class FileUploader {
|
|||||||
this.authToken = this.options.authToken;
|
this.authToken = this.options.authToken;
|
||||||
this.authTokenHeader = this.options.authTokenHeader || 'Authorization';
|
this.authTokenHeader = this.options.authTokenHeader || 'Authorization';
|
||||||
this.autoUpload = this.options.autoUpload;
|
this.autoUpload = this.options.autoUpload;
|
||||||
|
this.withCredentials = this.options.withCredentials;
|
||||||
|
|
||||||
this.options.filters.unshift({ name: 'queueLimit', fn: this._queueLimitFilter });
|
this.options.filters.unshift({ name: 'queueLimit', fn: this._queueLimitFilter });
|
||||||
|
|
||||||
if (this.options.maxFileSize) {
|
if (this.options.maxFileSize) {
|
||||||
@@ -357,7 +361,7 @@ export class FileUploader {
|
|||||||
this._onCompleteItem(item, response, xhr.status, headers);
|
this._onCompleteItem(item, response, xhr.status, headers);
|
||||||
};
|
};
|
||||||
xhr.open(item.method, item.url, true);
|
xhr.open(item.method, item.url, true);
|
||||||
xhr.withCredentials = item.withCredentials;
|
xhr.withCredentials = this.withCredentials !== null ? this.withCredentials : item.withCredentials;
|
||||||
if (this.options.headers) {
|
if (this.options.headers) {
|
||||||
for (let header of this.options.headers) {
|
for (let header of this.options.headers) {
|
||||||
xhr.setRequestHeader(header.name, header.value);
|
xhr.setRequestHeader(header.name, header.value);
|
||||||
|
|||||||
Reference in New Issue
Block a user