Upload thumbnail as a separate file


I am trying to create a feature where when an image file is added to the Dashboard, another thumbnail file is created and added based on the preview property of the initial file. Until now, I have tried two methods:

  1. Create the new file on the file-added trigger. Here it would enter an infinite loop that I have prevented with a thumbnail flag in the meta property of the created file. But this does not feel like a viable option as I need the upload of the thumbnail files to be invisible to the user.
  2. Use the addPreProcessor method to trigger the function that generated and uploads the thumbnail files. Here, I encountered several problems. The library only keeps track of the initial files for upload, so I have to manually trigger the upload process again for each thumbnail file. But when I trigger the upload process manually, the complete event triggers, and I need the event to trigger other external processes.

Anyone have any advice on how to implement this without any of the drawbacks I have described?

Hi, for option 1 did you use uppy.addFile()? The file should appear then :thinking:

I did use addFile. The problem I have with this approach is that the file gets added to the Dashboard before the upload process starts and the user can see the new file there. The way I need it to work is that I add the original file and when the user clicks on Upload, the thumbnail file is added to the upload queue in the background.
That is why I tried the addPreProcessor method, but then I encountered the multiple trigger of the complete event that has me blocked.

I’m afraid that only letting the new thumbnail files show up as you click upload, not before, is too specific for how Uppy is designed.

I understand that it’s a bit confusing to see files double from a user perspective, but it’s probably your best option.