Stop upload/process ant-design Upload component on beforeUpload event

2.2k views Asked by At

I'm trying to upload an image using ant-design. This is an example I just found on our community.

Using customRequest in Ant design file upload

this is Demo link

https://stackblitz.com/edit/so-58128062-upload-progress-4gyng9

I'm trying to add

  const beforeUpload = () => {
    return false; // STOP all actions including Upload and progres/preview
    //Using Hooks to update the state to the current filelist
    //filelist - [{uid: "-1",url:'Some url to image'}]
  };

to block all upload process/preview actions. But It's not working.

Thank you for helping

1

There are 1 answers

0
Rony Nguyen On

Yeah, I found it.

Just need set default list on onChange event to are empty then OK

  const handleOnChange = ({ file, fileList, event }) => {
     setDefaultFileList([]);
  };

Hope to help someone if you want similar behaviour

demo