Repository navigation
fix(plugin-cloud-storage): store processed bytes for cropped and mislabeled client uploads - #18913
Merged
nathanlentz merged 3 commits intoOct 23, 2026
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
nathanlentz
force-pushed
the
fix/client-upload-edits-3x
branch
2 times, most recently
from
October 22, 2026 01:22
72344e9 to
ca8cd9d
Compare
nathanlentz
force-pushed
the
fix/client-upload-edits-3x
branch
from
October 22, 2026 13:00
ca8cd9d to
21be9a0
Compare
JarrodMFlesch
force-pushed
the
fix/client-upload-edits-3x
branch
from
October 22, 2026 14:25
21be9a0 to
b50a632
Compare
JarrodMFlesch
approved these changes
Oct 22, 2026
JarrodMFlesch
force-pushed
the
fix/client-upload-edits-3x
branch
from
October 22, 2026 16:04
dec65d8 to
6f44ca4
Compare
nathanlentz
force-pushed
the
fix/client-upload-edits-3x
branch
from
October 22, 2026 18:45
6f44ca4 to
2353d53
Compare
JarrodMFlesch
force-pushed
the
fix/client-upload-edits-3x
branch
from
October 22, 2026 19:54
2353d53 to
c057e31
Compare
nathanlentz
force-pushed
the
fix/client-upload-edits-3x
branch
from
October 23, 2026 13:40
c057e31 to
1d98f01
Compare
nathanlentz
added a commit
that referenced
this pull request
Oct 23, 2026
#18388) ## Summary Fixes #18333, together with #18913. If Payload processed a direct-client upload, Vercel Blob, GCS, and R2 could store a zero-byte object. The document still reported the processed file size. These adapters now upload from the temporary file that holds the processed bytes. On 3.x, a crop with Vercel Blob first fails with a 500 error, so the crop case from the issue also needs #18913. ## What - For client uploads, Payload keeps the file on disk and does not load it into memory. After processing, the new bytes are in the temporary file and `file.data` is empty. - When `tempFilePath` is present, the Vercel Blob, GCS, and R2 adapters read the bytes from that file. S3 and Azure already do this. - R2 imports `fs` only when it needs the temporary file, because `fs` is not always available in Workers. <img width="882" height="1598" alt="CleanShot 2026-10-22 at 09 45 35" src="https://github.com/user-attachments/assets/a5472ae7-a0b8-4b62-beb3-d9eed96c2003" /> --------- Co-authored-by: Jarrod Flesch <[email protected]>
nathanlentz
added a commit
that referenced
this pull request
Oct 23, 2026
…RandomSuffix (#18920) Stacked on #18913. Review and merge #18388 and #18913 first. This PR does not depend on their changes. It is in the stack because #18921 changes the same adapter code. Fixes #9589. ## Summary With `addRandomSuffix: true`, Vercel Blob uploads the main file and each image size in parallel. Every upload wrote its suffixed name to the same `data.filename`. As a result, the document filename could point to an image size, and no image size got its suffixed name. Every image-size URL returned 404. Now each upload writes its suffixed name only to its own entry: an image size updates `sizes.<name>.filename`, and the main file updates `filename`. ## How - After each upload finishes, the adapter finds the image size whose filename matches the uploaded file. If no size matches, the file is the main file. - Two image sizes with the same dimensions get the same filename. The adapter finds the entry after the upload, so a size that an earlier upload renamed does not match again. Each size gets its own entry. - `storage-uploadthing` already uses this pattern for its per-file keys. - `plugin-cloud-storage` does not change. ## Tests - A unit test checks that the main file and an image size each update only their own filename. - A unit test uploads two image sizes with the same filename in parallel. It checks that each size gets its own suffixed filename. This test failed before this change. - An integration test uploads an image with one image size and `addRandomSuffix: true`. It checks that every filename on the document has an object in storage, and that the main object size is equal to the document `filesize`. This test failed on every run before this change. ## Related work - Stack: #18388 → #18913 → this PR → #18921 - The bug started in #5928, the first version of the storage packages. - Not in scope: #18384 (the create response has a `url` without the suffix) and #18804 (focal point with a new filename). --------- Co-authored-by: Jarrod Flesch <[email protected]>
nathanlentz
added a commit
that referenced
this pull request
Oct 23, 2026
…ploads with addRandomSuffix (#18921) Stacked on #18913. Review and merge #18388 and #18913 first. ## Summary With `addRandomSuffix: true`, a processed client upload was saved again under a new name with a suffix. The original file from the browser stayed in storage, and nothing used it. Now the processed file replaces the original file, and the document keeps the original filename. ## How - The server already saves the temp-file path of a client upload in `req.context` for cleanup. The adapter turns off `addRandomSuffix` when the file's `tempFilePath` is the same as that saved path. - The client cannot set this value, because the server sets both paths. - The check does not use `_objectKey`, so legacy overwrite receipts without `_objectKey` are covered too. - `payload` now exports `CLIENT_UPLOAD_TEMP_FILE_PATH_CONTEXT_KEY`, so the adapter does not copy the key string. ## Related work - Stack: #18388 → #18913 → this PR - Reported in a comment on #18333 and in the #18387 review. - #18920 fixes a separate `addRandomSuffix` bug with image sizes. Both PRs add `packages/storage-vercel-blob/src/adapter.spec.ts`, so the second one to merge needs a rebase.
Contributor
|
🚀 This is included in version v3.92.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #18388. Review and merge #18388 first.
Summary
Direct client uploads with a crop or a wrong MIME type do not store the processed file. A crop returns a 500 error. A file with a wrong MIME type keeps the original bytes in storage, but the document describes the processed file.
How
uploadEdits. Before, it applied the crop again and tried to download the file, which failed.mainalready does this.req.filenow points to the corrected copy of the file. Before, only the copy was marked as processed, so the storage plugin skipped the upload.resizeOptionsare both set, the temp file now gets the cropped and resized bytes. Before, it got only the cropped bytes.Tests
The resized client-upload test now also covers a cropped upload and an upload with a wrong MIME type. The test collection has an image size, so each case also covers crops together with
imageSizes. Each case checks that the stored sizes of the main file and the image size are equal to theirfilesizevalues on the document. Both new cases failed before this change.Related work