FineUploader/react-fine-uploader

Detect the last file in multiple select

omidnikrah opened this issue · 4 comments

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?

Why do you want to do this?

I want to call API after submitting all file and I need to detect the last item to call API.

Can you help me?

I suggest monitoring the statusChanged event, and checking the results of getUploads until there all files are submitted. see the docs for more details