Understanding `Uppy.onBeforeFileAdded(files, file)`

Hi!

I want to notify users when they try to upload the same file twice. As far as I understand, if this is done during the same session, Uppy detects it natively but doesn’t show a message.

I defined this Uppy object:

  const uppy = new Uppy({
    onBeforeFileAdded(file, files) {
      var match = Object.hasOwn(files, file.id);
      console.log('match', match);
      if (match) {
        uppy.info(
          `File "${file.name}" already uploaded`, 'error', 2000
        );
      }
      return !match;
    },
    debug: true,
  });

But this function is not working as expected. Note that it is mostly identical to the default function: (files, file) => !Object.hasOwn(files, file.id). The variable match is always False no matter if the file was previously uploaded during that session, reason why no info is showed to the user.

By default I do see the message displayed in the dashboard.

Sorry I misunderstood what in the same session meant. I thought it was since the creation of the Puppy object until it was destroyed ie page refresh, not only between upload and upload.

Nevertheless I’m getting two messages, the default and the one written by my function definition, how do I disable the standard?

Thanks!

Unfortunately you can’t disable the default message for now. It’s hardcoded.

Not exactly the same problem but a full custom locale is not possible. Another example is when the user selects to upload a non-allowed filetype… that message is not defined.

Thanks for the help