Search code examples
javascripttypescriptantd

Ant Design - Upload file into memory before posting


In the Ant Design examples they set the action property to specify a server to upload a file to. I would like to instead upload into memory and then post the contents to my server.

The Ant Design examples look like this.

const uploadProps = {
  name: 'file',
  action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
};

return (<Upload {...uploadProps}></Upload>);

How can this be achieved?


Solution

  • Have a look at the property customRequest of the Upload component (Antd Upload). There you can obtain the file as a property.