@uppy/aws-s3: fix server generated keys not getting returned - #6498
@uppy/aws-s3: fix server generated keys not getting returned #6498qxprakash wants to merge 15 commits into
Conversation
🦋 Changeset detectedLatest commit: ac1c708 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…t/uppy into fix/6496-server-generated-key
| }) | ||
|
|
||
| return { xhr, url } | ||
| return { xhr, url, signedKey: signedKey || request.key } |
There was a problem hiding this comment.
If the key your server signs for is not exactly the key it received, you must return it as key in the response. Otherwise Uppy assumes the object was stored under the key it requested.
This is the directive which we need add in our docs, sadly this wasn't the case previously, before the rewrite we used to return the key from the server
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| }) | ||
|
|
||
| return { xhr, url } | ||
| return { xhr, url, signedKey: signedKey || request.key } |
There was a problem hiding this comment.
| return { xhr, url, signedKey: signedKey || request.key } | |
| return { xhr, url, signedKey: signedKey } |
i don't like that it means two things, does it need to?
There was a problem hiding this comment.
yes it needs to, because what if the signer doesn't returns the key it has signed in it's response ? then we'll use the client generated key request.key is the client generated key, you can check the code paths #uploadNonMultipart -> putObject -> this.request the client generated key is propagated throughout, so we're using that same key in case the signing server doesn't sends it. if my explaination had muddled your understanding then let me know I'll try to elaborate a bit more 😂
|
i did an ai review: #6507 looks ok? then we can merge both |
fixes #6496
NO AI USED in code
we were always passing client generated keys from s3Opts methods ,
see :
in
#onSuccesswe're passing key returned from putObjectuppy/packages/@uppy/aws-s3/src/S3Uploader.ts
Lines 262 to 279 in 06ae391
putObjectdirectly returns the key it gets in params which is the client generated keyuppy/packages/@uppy/aws-s3/src/s3-client/S3mini.ts
Lines 179 to 201 in 06ae391
people can modify these keys on their signing backends, when a signing backend stores the object under a different key:
Single-part: upload succeeds, but upload-success reports a key that doesn't exist in the bucket. This is the reported issue in In @uppy/aws-s3 6.0, the key returned in file.response.body.key is the client-generated key, not the server-generated one #6496
Multipart: the reported key was correct (it's parsed from S3's
CompleteMultipartUploadresponse), but the client key was used internally for every part/complete/abort request and persisted ass3Multipart.keyforGolden Retriever. That only works if the server maps client→server key deterministically on every call; a server that generates a unique key fails at the firstuploadPartwithNoSuchUpload.Fix