我正在使用Ant Design Upload组件(https://ant.design/components/upload/)
该组件的配置如下:
<Upload.Dragger name="file"
fileList={this.state.files}
multiple={true}
openFileDialogOnClick={true}
showUploadList={false}
beforeUpload={this.onFileSelected}
onChange={this.onFileUploadChange}
action={_api.browse.url.upload(selected)}>
onFileUploadChange用于向用户显示通知:
onFileUploadChange = (info) => {
let uploading = false;
if (info.event) {
let progress = {};
let message = "Uploading in progress";
for (let file of info.fileList) {
progress[file.uid] = Math.round(file.percent);
if (!file.exception && file.percent < 100)
uploading = true;
}
if (!uploading) {
message = "Upload finished";
setTimeout(() => {
this.setState({ files: [], progress: {} });
notification.close('UploadNotifcation');
}, 3000);
}
this.setState({ progress }, () => this.uploadNotification(info, message));
} else {
this.setState({ files: info.fileList });
}
if (!uploading)
this.setDroppable(false);
}
是否可以取消/中止文件上传?例如,我想显示一个按钮,用户可以单击该按钮来取消文件上传。
任何建议,TIA都将不胜感激!