Repository navigation
feat(plugin-cloud-storage): implement storage packages - #5928
Merged
Merged
Conversation
denolfe
force-pushed
the
feat/storage-adapter-packages
branch
from
April 21, 2024 12:45
843a4e4 to
a0bcc3a
Compare
denolfe
force-pushed
the
feat/storage-adapter-packages
branch
from
April 22, 2024 02:51
e88b421 to
f27f169
Compare
denolfe
marked this pull request as ready for review
April 22, 2024 12:26
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]>
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.
Description
This will have an accompanying breaking change before release to remove the existing adapters from
@payloadcms/plugin-cloud-storagein favor of these packages.Splitting out each adapter into their own standalone, functional packages. This was needed because there were a lack of warnings when enforcing optional peer dependency version ranges. The experience will also be much nicer.
The goal is to have the user only install the storage package that they need, and not need to install
@payloadcms/plugin-cloud-storageor peer dependencies directly - it will be used internally within the storage packages.All existing cloud-storage adapters will be removed from
@payloadcms/plugin-cloud-storageUsage before:
Required peer dependencies to be installed
Usage after:
No peer dependencies