Skip to content
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

Using this we can view the response of server #916

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions src/file-upload/file-item.class.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { FileLikeObject } from './file-like-object.class';
import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file-uploader.class';

import {Observable} from "rxjs/Rx";

export class FileItem {
public observer:any;
/**
* Observable for subscribing the server result
*/
public resObservable:Observable;
public file:FileLikeObject;
public _file:File;
public alias:string;
Expand Down Expand Up @@ -36,6 +43,7 @@ export class FileItem {
this.alias = uploader.options.itemAlias || 'file';
}
this.url = uploader.options.url;
this.resObservable=new Observable.create(observer=>{this.observer=observer});
}

public upload():void {
Expand Down
5 changes: 3 additions & 2 deletions src/file-upload/file-uploader.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export class FileUploader {
if (!options) {
options = this.options;
}

let temp = new FileLikeObject(some);
if (this._isValidFile(temp, arrayOfFilters, options)) {
let fileItem = new FileItem(this, some, options);
Expand Down Expand Up @@ -278,6 +277,7 @@ export class FileUploader {
}
this.onCompleteAll();
this.progress = this._getTotalProgress();
this.item.observer.next(response);
this._render();
}

Expand Down Expand Up @@ -328,7 +328,8 @@ export class FileUploader {
let gist = this._isSuccessCode(xhr.status) ? 'Success' : 'Error';
let method = '_on' + gist + 'Item';
(this as any)[method](item, response, xhr.status, headers);
this._onCompleteItem(item, response, xhr.status, headers);
this._
(item, response, xhr.status, headers);
};
xhr.onerror = () => {
let headers = this._parseHeaders(xhr.getAllResponseHeaders());
Expand Down
6 changes: 6 additions & 0 deletions src/file-upload/rxjs/operator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/toPromise';