Repository navigation
fix(storage-vercel-blob): keep image-size filenames separate with addRandomSuffix - #18920
nathanlentz merged 3 commits into
Conversation
📦 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.
|
|
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 |
832d401 to
9cd85b6
Compare
9cd85b6 to
4b46685
Compare
74b1058 to
c269494
Compare
c269494 to
4ad1b71
Compare
|
We should follow up by using For example, these two image-size configurations produce different JPEG bytes but the same default filename, upload: {
imageSizes: [
{
name: 'preview',
width: 400,
height: 400,
formatOptions: {
format: 'jpeg',
options: { quality: 40 },
},
},
{
name: 'download',
width: 400,
height: 400,
formatOptions: {
format: 'jpeg',
options: { quality: 90 },
},
},
],
}The default filename includes the output dimensions and extension, but neither the configured size name nor the JPEG quality. This assumes the source is large enough for both sizes to be generated. |
45ef47e to
843b2ce
Compare
843b2ce to
3124df4
Compare
…abeled client uploads (#18913) 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 - The storage plugin runs a second update to save adapter metadata. That update now runs without `uploadEdits`. Before, it applied the crop again and tried to download the file, which failed. `main` already does this. - When Payload corrects the MIME type, `req.file` now points to the corrected copy of the file. Before, only the copy was marked as processed, so the storage plugin skipped the upload. - When a crop and `resizeOptions` are 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 their `filesize` values on the document. Both new cases failed before this change. ## Related work - Stack: #18388 → this PR → #18920 → #18921 - Issue: #18333 --------- Co-authored-by: Jarrod Flesch <[email protected]>
…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.
|
🚀 This is included in version v3.92.1 |
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 samedata.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 updatesfilename.How
storage-uploadthingalready uses this pattern for its per-file keys.plugin-cloud-storagedoes not change.Tests
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 documentfilesize. This test failed on every run before this change.Related work
Stack: fix(storage-vercel-blob): upload processed client files from temp file #18388 → fix(plugin-cloud-storage): store processed bytes for cropped and mislabeled client uploads #18913 → this PR → fix(storage-vercel-blob): keep the receipt key for processed client uploads with addRandomSuffix #18921
The bug started in feat(plugin-cloud-storage): implement storage packages #5928, the first version of the storage packages.
Not in scope: storage-vercel-blob with
addRandomSuffix: a create or a file replacement answers with aurlthat gives 404 #18384 (the create response has aurlwithout the suffix) and plugin-cloud-storage: upload with a focal point set before first save fails when the adapter returns a new filename (e.g. Vercel Blob addRandomSuffix) #18804 (focal point with a new filename).