Skip to content

Commit

Permalink
Gets the XMLHttpRequest Object in Onchange function (#19539)
Browse files Browse the repository at this point in the history
  • Loading branch information
hahmadia authored and afc163 committed Nov 4, 2019
1 parent 53efaa8 commit 2144589
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/upload/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Upload extends React.Component<UploadProps, UploadState> {
}
};

onSuccess = (response: any, file: UploadFile) => {
onSuccess = (response: any, file: UploadFile, xhr: any) => {
this.clearProgressTimer();
try {
if (typeof response === 'string') {
Expand All @@ -120,6 +120,7 @@ class Upload extends React.Component<UploadProps, UploadState> {
}
targetItem.status = 'done';
targetItem.response = response;
targetItem.xhr = xhr;
this.onChange({
file: { ...targetItem },
fileList,
Expand Down
3 changes: 2 additions & 1 deletion components/upload/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ When uploading state change, it returns:
```js
{
uid: 'uid', // unique identifier, negative is recommend, to prevent interference with internal generated id
name: 'xx.png' // file name
name: 'xx.png', // file name
status: 'done', // options:uploading, done, error, removed
response: '{"status": "success"}', // response from server
linkProps: '{"download": "image"}', // additional html props of file link
xhr: 'XMLHttpRequest{ ... }', // XMLHttpRequest Header
}
```

Expand Down
1 change: 1 addition & 0 deletions components/upload/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface UploadFile<T = any> {
error?: any;
linkProps?: any;
type: string;
xhr?: T;
}

export interface UploadChangeParam<T extends object = UploadFile> {
Expand Down

0 comments on commit 2144589

Please sign in to comment.