Detect the last file in multiple select
omidnikrah opened this issue · 4 comments
omidnikrah commented
Hi, I want to detect the last file in multiple select. I call an API per file on submit and I want to detect the last item to display a message.
Previously I wrote the following code but it's wrong because ID is not a number to check with the length of files.
UploaderConfig.on('submitted', (id : any) => {
const uploadLength = UploaderConfig.methods.getUploads('SUBMITTING').length;
if (id+1 === uploadLength) {
alert('The last file')
}
});
How can I detect the last file?
rnicholus commented
Why do you want to do this?
omidnikrah commented
I want to call API after submitting all file and I need to detect the last item to call API.
omidnikrah commented
Can you help me?
rnicholus commented
I suggest monitoring the statusChanged event, and checking the results of getUploads until there all files are submitted. see the docs for more details