Updated: auth token support & small TS fix #8

This commit is contained in:
buchslava
2015-12-02 17:09:15 +02:00
parent 3706b12542
commit 80b066c021
2 changed files with 7 additions and 1 deletions

View File

@@ -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) {
}

View File

@@ -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();
}