fix(client/upload): fix upload mutiple files always uploading status (#974)
This commit is contained in:
parent
b9910cdc1f
commit
8df527f7e9
@ -167,12 +167,13 @@ export function useUploadProps<T extends IUploadProps = UploadProps>({ serviceEr
|
|||||||
props.onChange?.(normalizeFileList([...param.fileList]));
|
props.onChange?.(normalizeFileList([...param.fileList]));
|
||||||
};
|
};
|
||||||
|
|
||||||
const form = useForm();
|
|
||||||
|
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...props,
|
...props,
|
||||||
|
// in customRequest method can't modify form's status(e.g: form.disabled=true )
|
||||||
|
// that will be trigger Upload component(actual Underlying is AjaxUploader component )'s componentWillUnmount method
|
||||||
|
// which will cause multiple files upload fail
|
||||||
customRequest({ action, data, file, filename, headers, onError, onProgress, onSuccess, withCredentials }) {
|
customRequest({ action, data, file, filename, headers, onError, onProgress, onSuccess, withCredentials }) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -181,7 +182,6 @@ export function useUploadProps<T extends IUploadProps = UploadProps>({ serviceEr
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
formData.append(filename, file);
|
formData.append(filename, file);
|
||||||
form.disabled = true;
|
|
||||||
api.axios
|
api.axios
|
||||||
.post(action, formData, {
|
.post(action, formData, {
|
||||||
withCredentials,
|
withCredentials,
|
||||||
@ -194,9 +194,7 @@ export function useUploadProps<T extends IUploadProps = UploadProps>({ serviceEr
|
|||||||
onSuccess(data, file);
|
onSuccess(data, file);
|
||||||
})
|
})
|
||||||
.catch(onError)
|
.catch(onError)
|
||||||
.finally(() => {
|
.finally(() => {});
|
||||||
form.disabled = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
abort() {
|
abort() {
|
||||||
|
Loading…
Reference in New Issue
Block a user