@@ -171,32 +171,35 @@ class AjaxUploader extends Component<UploadProps> {
171171 if ( ! this . _isMounted ) {
172172 return ;
173173 }
174- const { props } = this ;
175- const { onStart, onProgress } = props ;
174+
175+ const { onStart, customRequest , name , headers , withCredentials , method } = this . props ;
176176
177177 const { uid } = origin ;
178- const request = props . customRequest || defaultRequest ;
178+ const request = customRequest || defaultRequest ;
179179
180180 const requestOption = {
181181 action,
182- filename : props . name ,
182+ filename : name ,
183183 data,
184184 file : parsedFile ,
185- headers : props . headers ,
186- withCredentials : props . withCredentials ,
187- method : props . method || 'post' ,
188- onProgress : onProgress
189- ? ( e : UploadProgressEvent ) => {
190- onProgress ( e , origin ) ;
191- }
192- : null ,
185+ headers,
186+ withCredentials,
187+ method : method || 'post' ,
188+ onProgress : ( e : UploadProgressEvent ) => {
189+ const { onProgress } = this . props ;
190+ onProgress ?.( e , origin ) ;
191+ } ,
193192 onSuccess : ( ret : any , xhr : XMLHttpRequest ) => {
193+ const { onSuccess } = this . props ;
194+ onSuccess ?.( ret , origin , xhr ) ;
195+
194196 delete this . reqs [ uid ] ;
195- props . onSuccess ( ret , origin , xhr ) ;
196197 } ,
197198 onError : ( err : UploadRequestError , ret : any ) => {
199+ const { onError } = this . props ;
200+ onError ?.( err , ret , origin ) ;
201+
198202 delete this . reqs [ uid ] ;
199- props . onError ( err , ret , origin ) ;
200203 } ,
201204 } ;
202205
0 commit comments