uppy
uppy copied to clipboard
brittle behaviour in AwsS3 with shouldUseMultipart and getPlugin
Initial checklist
- [X] I understand this is a bug report and questions should be posted in the Community Forum
- [X] I searched issues and couldn’t find anything (or linked relevant results below)
Link to runnable example
No response
Steps to reproduce
- Initialise Uppy outside a React component and use the
AwsS3
plugin with{ shouldUseMultipart: true }
- Call
uppy.getPlugin('AwsS3').getOptions({ ... })
from inside component
Expected behavior
Should be able to modify the options dynamically from inside the component, for example to set callbacks that depend on the component state.
Actual behavior
The result of getPlugin('AwsS3')
is undefined and setOptions()
fails with an undefined error.
The work around is to call this inside the component instead:
uppy.getPlugin('AwsS3Multipart').getOptions({ ... })
The reason seems to be that setting { shouldUseMultipart: true }
replaces the AwsS3 plugin with the AwsS3Multipart plugin, which means the plugin registry doesn't contain AwsS3
so the getPlugin('AwsS3')
call fails.
In addition to this, I also discovered that { shouldUseMultipart: true }
must be set inside the very first use(AwsS3, { ... })
call. Trying to set it later using setOptions()
has no effect. In my case I have not set up Uppy for single part uploads, so this led to a signal
undefined error deep inside Uppy that was quite difficult to diagnose.
I understand that both of these issues are only transitional, but I do recommend at least documenting them as I found both issues quite time consuming to diagnose and fix.