How to implement customRequest correctly by upload component in antd

now there is a requirement that when I upload a picture, I need a form form item with a user ID. If I follow the default request method of the upload component, I cannot upload any element other than the picture. Now I rewrite customRequest:

.
customRequest = (detail) => {
    console.log(detail)
    uploadPicture && uploadPicture(detail.file).then((res) => {
        console.log(res.success)
    })
}

<Upload
    accept="image/*"
    listType="picture-card"
    fileList={fileList}
    action={`${api.uploadPicture}`}
    multiple={true}
    customRequest={this.customRequest}
    withCredentials={true}
    beforeUpload={this.beforeUpload}
    onChange={handleFileListChange}>
    
                </Upload>

but if you write according to the above, there will actually be a problem, that is, there is no way to update the upload status of the picture. I don"t know how to write the correct customRequest. Can you give me an example

?
Apr.02,2021

it is very complicated to customize a customRequest. It is recommended to throw the user's identity in the header
customRequest-examples


if allowed. It solves my problem

.
Menu