Merge pull request #9 from valor-software/feature-auth-token-support
Updated: auth token support & small TS fix #8
This commit is contained in:
@@ -27,6 +27,11 @@ Easy to use Angular2 directives for files upload ([demo](http://valor-software.g
|
|||||||
|
|
||||||
- `uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
- `uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
||||||
|
|
||||||
|
Parameters that supported by this object:
|
||||||
|
|
||||||
|
1. `url` - URL of File Uploader's route
|
||||||
|
2. `authToken` - Auth token that will be applied as 'Authorization' header during file send.
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
- `file-over` - it fires during 'over' and 'out' events for Drop Area; returns `boolean`: `true` if file is over Drop Area, `false` in case of out.
|
- `file-over` - it fires during 'over' and 'out' events for Drop Area; returns `boolean`: `true` if file is over Drop Area, `false` in case of out.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ function isFileLikeObject(value:any) {
|
|||||||
|
|
||||||
export class FileUploader {
|
export class FileUploader {
|
||||||
public url:string;
|
public url:string;
|
||||||
|
public authToken:string;
|
||||||
public isUploading:boolean = false;
|
public isUploading:boolean = false;
|
||||||
public queue:Array<any> = [];
|
public queue:Array<any> = [];
|
||||||
public progress:number = 0;
|
public progress:number = 0;
|
||||||
@@ -29,6 +30,7 @@ export class FileUploader {
|
|||||||
constructor(public options:any) {
|
constructor(public options:any) {
|
||||||
// Object.assign(this, options);
|
// Object.assign(this, options);
|
||||||
this.url = options.url;
|
this.url = options.url;
|
||||||
|
this.authToken = options.authToken;
|
||||||
this.filters.unshift({name: 'queueLimit', fn: this._queueLimitFilter});
|
this.filters.unshift({name: 'queueLimit', fn: this._queueLimitFilter});
|
||||||
this.filters.unshift({name: 'folder', fn: this._folderFilter});
|
this.filters.unshift({name: 'folder', fn: this._folderFilter});
|
||||||
}
|
}
|
||||||
@@ -335,6 +337,10 @@ export class FileUploader {
|
|||||||
xhr.setRequestHeader(name, value);
|
xhr.setRequestHeader(name, value);
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
|
if (this.authToken) {
|
||||||
|
xhr.setRequestHeader('Authorization', this.authToken);
|
||||||
|
}
|
||||||
|
|
||||||
xhr.send(form);
|
xhr.send(form);
|
||||||
this._render();
|
this._render();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ import {FileSelect, FileDrop, FileUploader} from 'ng2-file-upload';
|
|||||||
|
|
||||||
- `uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
- `uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)
|
||||||
|
|
||||||
|
Parameters that supported by this object:
|
||||||
|
|
||||||
|
1. `url` - URL of File Uploader's route
|
||||||
|
2. `authToken` - auth token that will be applied as 'Authorization' header during file send.
|
||||||
|
|
||||||
## FileDrop API
|
## FileDrop API
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ng2-file-upload",
|
"name": "ng2-file-upload",
|
||||||
"version": "0.44.0",
|
"version": "0.46.0",
|
||||||
"description": "angular2 file upload directives",
|
"description": "angular2 file upload directives",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"deploy": "NODE_ENV=production webpack -p --progress --color --optimize-minimize --optimize-dedupe --optimize-occurence-order",
|
"deploy": "NODE_ENV=production webpack -p --progress --color --optimize-minimize --optimize-dedupe --optimize-occurence-order",
|
||||||
|
|||||||
Reference in New Issue
Block a user