I’ve been using Uppy to handle image uploads for my users, and it’s great! The problem is that I need to run an API call to get a target upload URL before the upload starts. The target URL depends on the file name the user added, so I need to run this call after the user adds a file, but before the upload starts.
I tried to implement a solution with an Uppy plugin and the uppy.addPreProcessor() method, but I encountered a different problem in doing this…my project uses @uppy/core 1.20.1, but the docs are for @uppy/core 2.0, and the plugin API seems to have changed. So I have two questions:
Is the plugin approach the best way to do this?
Are there docs available for the old version that used Plugin instead of BasePlugin and UIPlugin?
Okay, I managed to migrate the project to use the latest version of Uppy. However, I still am having trouble with the upload. The solution proposed in the linked comment isn’t working for me, but I’m using it in a bit of a different way. Rather than call uppy.setFileState from within an event handler, I’m calling it from within a callback passed to addPreProcessor within a plugin. This approach is more suitable for async calls. However, it seems like the endpoint is not being overridden; the bogus endpoint I’m providing initially when setting up XHRUpload is still being used. I have to provide this endpoint because XHRUpload is throwing an error if I don’t.
This is the function in question. Instance is a reference to an axios instance.