1- import { NgZone } from '@angular/core' ;
2-
31import { FileLikeObject } from './file-like-object.class' ;
4- import { FileUploader } from './file-uploader.class' ;
2+ import { FileUploader , ParsedResponseHeaders , FileUploaderOptions } from './file-uploader.class' ;
53
64export class FileItem {
75 public file :FileLikeObject ;
@@ -20,28 +18,28 @@ export class FileItem {
2018 public isError :boolean = false ;
2119 public progress :number = 0 ;
2220 public index :number = void 0 ;
23- private _zone :NgZone ;
21+ public _xhr :XMLHttpRequest ;
22+ public _form :any ;
2423
2524 private uploader :FileUploader ;
26- private some :any ;
27- private options :any ;
25+ private some :File ;
26+ private options :FileUploaderOptions ;
2827
29- public constructor ( uploader :FileUploader , some :any , options :any ) {
28+ public constructor ( uploader :FileUploader , some :File , options :FileUploaderOptions ) {
3029 this . uploader = uploader ;
3130 this . some = some ;
3231 this . options = options ;
3332 this . file = new FileLikeObject ( some ) ;
3433 this . _file = some ;
3534 this . url = uploader . options . url ;
36- this . _zone = new NgZone ( { enableLongStackTrace : false } ) ;
3735 }
3836
3937 public upload ( ) :void {
4038 try {
4139 this . uploader . uploadItem ( this ) ;
4240 } catch ( e ) {
43- this . uploader . _onCompleteItem ( this , '' , 0 , [ ] ) ;
44- this . uploader . _onErrorItem ( this , '' , 0 , [ ] ) ;
41+ this . uploader . _onCompleteItem ( this , '' , 0 , { } ) ;
42+ this . uploader . _onErrorItem ( this , '' , 0 , { } ) ;
4543 }
4644 }
4745
@@ -65,19 +63,19 @@ export class FileItem {
6563 return { progress} ;
6664 }
6765
68- public onSuccess ( response :any , status :any , headers :any ) :any {
66+ public onSuccess ( response :string , status :number , headers :ParsedResponseHeaders ) :any {
6967 return { response, status, headers} ;
7068 }
7169
72- public onError ( response :any , status :any , headers :any ) :any {
70+ public onError ( response :string , status :number , headers :ParsedResponseHeaders ) :any {
7371 return { response, status, headers} ;
7472 }
7573
76- public onCancel ( response :any , status :any , headers :any ) :any {
74+ public onCancel ( response :string , status :number , headers :ParsedResponseHeaders ) :any {
7775 return { response, status, headers} ;
7876 }
7977
80- public onComplete ( response :any , status :any , headers :any ) :any {
78+ public onComplete ( response :string , status :number , headers :ParsedResponseHeaders ) :any {
8179 return { response, status, headers} ;
8280 }
8381
@@ -97,13 +95,11 @@ export class FileItem {
9795 }
9896
9997 public _onProgress ( progress :number ) :void {
100- this . _zone . run ( ( ) => {
101- this . progress = progress ;
102- } ) ;
98+ this . progress = progress ;
10399 this . onProgress ( progress ) ;
104100 }
105101
106- public _onSuccess ( response :any , status :any , headers :any ) :void {
102+ public _onSuccess ( response :string , status :number , headers :ParsedResponseHeaders ) :void {
107103 this . isReady = false ;
108104 this . isUploading = false ;
109105 this . isUploaded = true ;
@@ -115,7 +111,7 @@ export class FileItem {
115111 this . onSuccess ( response , status , headers ) ;
116112 }
117113
118- public _onError ( response :any , status :any , headers :any ) :void {
114+ public _onError ( response :string , status :number , headers :ParsedResponseHeaders ) :void {
119115 this . isReady = false ;
120116 this . isUploading = false ;
121117 this . isUploaded = true ;
@@ -127,7 +123,7 @@ export class FileItem {
127123 this . onError ( response , status , headers ) ;
128124 }
129125
130- public _onCancel ( response :any , status :any , headers :any ) :void {
126+ public _onCancel ( response :string , status :number , headers :ParsedResponseHeaders ) :void {
131127 this . isReady = false ;
132128 this . isUploading = false ;
133129 this . isUploaded = false ;
@@ -139,7 +135,7 @@ export class FileItem {
139135 this . onCancel ( response , status , headers ) ;
140136 }
141137
142- public _onComplete ( response :any , status :any , headers :any ) :void {
138+ public _onComplete ( response :string , status :number , headers :ParsedResponseHeaders ) :void {
143139 this . onComplete ( response , status , headers ) ;
144140
145141 if ( this . uploader . options . removeAfterUpload ) {
0 commit comments