@uppy/aws-s3: setOptions() silently ignores the signing options
Follow-up from #4795, which is otherwise fixed in v6.
Problem
setOptions() has no effect for signRequest, getCredentials and companionEndpoint. The client is built once in install() and keeps its own copy of the callback, so the original one is used for every upload. Nothing throws or warns.
uppy.use(AwsS3, { signRequest: signA, shouldUseMultipart: false })
uppy.getPlugin('AwsS3').setOptions({ signRequest: signB })
await uppy.upload() // signA runsOther options (shouldUseMultipart, generateObjectKey, getChunkSize, allowedMetaFields) are re-read per file and do update, so there is no way to tell which options are live and which are frozen.
This is a documented API (setOptions), and our React guide recommends exactly this pattern for passing component values into a plugin:
uppy.getPlugin('Webcam').setOptions({ modes: props.webcamModes })It also worked in v5: AwsS3 overrode setOptions() to rebuild its Companion client and re-wrap all eight signing callbacks, so v5 code that swaps a signer at runtime silently stops working on v6.
Example of Why someone would need this
A signer that depends on component state, which is the case #4795 originally reported:
// the folder the user picked decides where the object goes
const [folder, setFolder] = useState('inbox')
useEffect(() => {
uppy.getPlugin('AwsS3').setOptions({
signRequest: (req) => fetch('/s3/sign', {
method: 'POST',
body: JSON.stringify({ ...req, folder }),
}).then((r) => r.json()),
})
}, [folder])
Today the upload keeps signing with the first folder value.
Two possible outomes :
A. Support it : rebuild the client when a signing option changes. Note that setOptions() merges rather than replaces, and #initS3Client() picks the first present key (companionEndpoint → getCredentials → signRequest`), so switching mode needs explicit handling. Also, each S3Uploader captures the client at construction, so a rebuild only affects uploads started afterwards.
B. Reject it : throw or warn for these keys and document them as install-time only.
Source: transloadit/uppy