Updated: auth token support & small TS fix #8
This commit is contained in:
@@ -18,7 +18,7 @@ import {FileUploader} from './file-uploader';
|
||||
})
|
||||
export class FileDrop {
|
||||
public uploader:FileUploader;
|
||||
private fileOver:EventEmitter<any> = new EventEmitter();
|
||||
private fileOver:EventEmitter = new EventEmitter();
|
||||
|
||||
constructor(private element:ElementRef) {
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ function isFileLikeObject(value:any) {
|
||||
|
||||
export class FileUploader {
|
||||
public url:string;
|
||||
public authToken:string;
|
||||
public isUploading:boolean = false;
|
||||
public queue:Array<any> = [];
|
||||
public progress:number = 0;
|
||||
@@ -29,6 +30,7 @@ export class FileUploader {
|
||||
constructor(public options:any) {
|
||||
// Object.assign(this, options);
|
||||
this.url = options.url;
|
||||
this.authToken = options.authToken;
|
||||
this.filters.unshift({name: 'queueLimit', fn: this._queueLimitFilter});
|
||||
this.filters.unshift({name: 'folder', fn: this._folderFilter});
|
||||
}
|
||||
@@ -335,6 +337,10 @@ export class FileUploader {
|
||||
xhr.setRequestHeader(name, value);
|
||||
});*/
|
||||
|
||||
if (this.authToken) {
|
||||
xhr.setRequestHeader('Authorization', this.authToken);
|
||||
}
|
||||
|
||||
xhr.send(form);
|
||||
this._render();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user