Browse Source

Gets the XMLHttpRequest Object in Onchange function (#19539)

pull/19544/head
Hossein Ahmadian-Yazdi 5 years ago
committed by 偏右
parent
commit
214458931d
  1. 3
      components/upload/Upload.tsx
  2. 3
      components/upload/index.en-US.md
  3. 1
      components/upload/interface.tsx

3
components/upload/Upload.tsx

@ -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') {
@ -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,

3
components/upload/index.en-US.md

@ -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
}
```

1
components/upload/interface.tsx

@ -40,6 +40,7 @@ export interface UploadFile<T = any> {
error?: any;
linkProps?: any;
type: string;
xhr?: T;
}
export interface UploadChangeParam<T extends object = UploadFile> {

Loading…
Cancel
Save