@@ -171,32 +171,35 @@ class AjaxUploader extends Component<UploadProps> {
171
171
if ( ! this . _isMounted ) {
172
172
return ;
173
173
}
174
- const { props } = this ;
175
- const { onStart, onProgress } = props ;
174
+
175
+ const { onStart, customRequest , name , headers , withCredentials , method } = this . props ;
176
176
177
177
const { uid } = origin ;
178
- const request = props . customRequest || defaultRequest ;
178
+ const request = customRequest || defaultRequest ;
179
179
180
180
const requestOption = {
181
181
action,
182
- filename : props . name ,
182
+ filename : name ,
183
183
data,
184
184
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
+ } ,
193
192
onSuccess : ( ret : any , xhr : XMLHttpRequest ) => {
193
+ const { onSuccess } = this . props ;
194
+ onSuccess ?.( ret , origin , xhr ) ;
195
+
194
196
delete this . reqs [ uid ] ;
195
- props . onSuccess ( ret , origin , xhr ) ;
196
197
} ,
197
198
onError : ( err : UploadRequestError , ret : any ) => {
199
+ const { onError } = this . props ;
200
+ onError ?.( err , ret , origin ) ;
201
+
198
202
delete this . reqs [ uid ] ;
199
- props . onError ( err , ret , origin ) ;
200
203
} ,
201
204
} ;
202
205
0 commit comments