How do I tell the custom onSuccess function to stop the upload spinner in Ant Design Upload component?

antupload
antd drag and drop
antd upload customrequest
antd upload s3
antd upload base64
antd download file
file upload component
antd beforeupload promise

I have this code:

render() {
    const props = {
      onChange: this.handleChange,
      multiple: true,
      name: 'datafiles[]',
      defaultFileList: this.initialState.fileList,
      listType: "text",
      onSuccess: (resp, file, xhr) => {
        file.status = 'done';
        const newDatafile = {
          filename: file.name,
          s3ObjectKey: `${this.props.userId}/${this.props.datasetId}`,
          filesizeBytes: file.size
        }
        this.props.saveNewDatafile(newDatafile, (saveError, savedJob) => {
            //Yadda yadda
        })
      },
      showUploadList: {
        showPreviewIcon: true,
        showRemoveIcon: true
      },
      customRequest: customRequest
    };

As you can see, I am using the customRequest. If I don't pass the onSuccess function, then the component works properly on success. But when I pass it, the progress bar reaches the end, but it still shows the spinner as if it was still uploading.

Pesky spinner before the filename

How do I tell the Upload component that the upload finished? I tried with the file.status = 'done' in a sad attempt to fix it, but no luck. I need the custom onSuccess function so I can call the saveNewDatafile function.


I fixed it by using the onChange function instead of the onSuccess function, and adding a conditional if (file.status === 'done')

Upload, Click to upload user's avatar, and validate size and format of picture with beforeUpload . The return value of function beforeUpload can be a Promise to check  3 How do I tell the custom onSuccess function to stop the upload spinner in Ant Design Upload component? Nov 6 '17. 2 Returning value from a different row in a CASE


After digging into src of upload component, I think it's impossible to use customRequest to control upload status, we have on way to set status in callback onSuccess.

https://github.com/ant-design/ant-design/blob/d89ffcc5b22cd7a722e1d9740f2f6f04c014f09b/components/upload/Upload.tsx#L77-L97

That said, I found an example in the repo of antd to upload manually.

It seems antd prefer callback onChange instead of onSuccess/onError directly.

Spin, A spinner for displaying loading state of a page or a section. Customized description content. expand code. import { Spin Use custom loading indicator. Today I went into Upload Center; selected to "Resume Uploads", and the uploads resumed. But having to manually check to make sure everything is working OK is an extra step in the sync'ing process that can eventually lead to significant errors, should I overlook that step.


const preventRequest = () => false;

<Upload beforeUpload={preventRequest}>
  <Button>
    <Icon type="upload" /> upload
  </Button>
</Upload>

Antd upload example, Ant Design Pro; Change Log; rc-components; Mobile UI; Ant Design Icons; Ant How do I tell the custom onSuccess function to stop the upload spinner in Ant  Canceling Upload. The server may create a temporary file(s) on the server side when upload started. To completely break the upload and remove any temporary files on the server side call IResumableUpload.CancelUpload method. This will signal to the server that you do not plan to restore the upload.


Managing File Uploads in React with Ant Design, Ant Design's Upload component makes this process extremely… If you're planning on loading the styles with Webpack, check out this StackOverflow etc)​, as well as other form input validators and custom functions. Using a custom image as an app icon (April 11, 2018) In Power Apps Studio for Windows version 3.18043, you cannot upload a custom image to use as an app icon. To work around this issue, use Power Apps Studio for web to upload a custom image. Alternatively, you can use one of the icons included with Power Apps Studio for Windows and customize


Upload Component upload file success when return false on , Upload Component upload file success when return false on beforeUpload function # ant-design-bot assigned dengfuping on Jan 11, 2018. Design and Architecture I solve it..it works..need to call abort method on current cancel button on which we have to abort the file upload.. // These function i


Ant Design Sketch, Ninet use unique UI components, created special for React application, which How do I tell the custom onSuccess function to stop the upload spinner in Ant  A customized upload button. It opens a file dialog. There is a hacky way to implement a customized file input. It breaks down into the followings: create a wrapper with relative positioning and hidden overflows; create a button with any design; create a large floating file input with zero opacity to capture clicks