对于文件多重上传,<FilePond>
我想确保没有重复的文件名,比如如果有两个文件具有相同的名称,那么它应该像 file.pdf 而另一个文件应该得到 file(1).pdf 等等。我怎样才能做到这一点?
<FilePond
ref={ref => this.pond = ref}
allowMultiple={true}
acceptedFileTypes= 'application/pdf'
onaddfile={async (error, fileItem) => {
let obj = {};
obj.id = fileItem.id;
obj.name = fileItem.file.name;
//obj.filestring = await this.toBase64(fileItem.file);
obj.file=fileItem.file;
obj.fileinProgress = false;
obj.date = this.state.date;
obj.report_type = this.state.selectedButton;
obj.fileItem = fileItem.fileType;
obj.readyToUpload = true;
obj.fileUploaded = false;
if (fileItem.fileType === 'application/pdf') {
this.setState({ ["files" + obj.id]: obj});
} else {
toast.error("You can only upload PDF file");
}
}} />