feat(storage-*): add useCompositePrefixes option and fix client upload prefix handling#16230
Merged
JarrodMFlesch merged 10 commits intomainfrom Apr 10, 2026
Merged
feat(storage-*): add useCompositePrefixes option and fix client upload prefix handling#16230JarrodMFlesch merged 10 commits intomainfrom
JarrodMFlesch merged 10 commits intomainfrom
Conversation
…te prefixes Adds centralized getFileKey utility with sanitization for computing file paths. Updates all storage adapters (S3, Azure, GCS, R2, Vercel Blob) to use getFileKey and support the future_compositePrefixes option. Updates client upload handlers to pass docPrefix through the upload chain.
- Add useCompositePrefixes option to all storage adapters (S3, Azure, GCS, R2, Vercel Blob) - Update all handlers to use getFileKey utility with collectionPrefix - Add integration tests for composite prefix functionality - Tests verify files are stored at collectionPrefix/docPrefix/filename when enabled
- Add useCompositePrefixes option to all adapter configuration tables - Add new "Prefix Composition" section explaining the behavior - Document the difference between legacy (override) and composite prefix modes
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.
|
…eKey handling Merge URI decoding and path normalization into sanitizePrefix, import it from getFilePrefix, export from utilities, and avoid double-sanitizing static collection prefixes in getFileKey.
… defaults Add PluginOptions.useCompositePrefixes so adapters can skip pre-filling the document prefix field when using compositional prefixes. Sanitize collection prefix values passed to adapters and getFields. Align admin stub with the same sanitization.
Forward the flag from object-storage adapters. For uploadthing, force an empty collection prefix and disable compositional prefixes since storage uses opaque file keys rather than path-scoped keys.
…ify test configs - Sanitize collection and doc segments in getFileKey for storage object keys - Pass options.prefix through plugin and admin without sanitizePrefix or empty-string fallback - Match admin prefix field defaultValue to server getFields - Add buildPluginCloudStorageIntConfig with config.ts vs config.compositePrefixes.ts - Split composite S3 tests into int.compositePrefixes.int.spec.ts; tighten int.spec types
paulpopus
approved these changes
Apr 10, 2026
Raghvendra2420
pushed a commit
to Raghvendra2420/payload
that referenced
this pull request
Apr 13, 2026
…d prefix handling (payloadcms#16230) ## Summary - Adds `useCompositePrefixes` option to all storage adapters (S3, Azure, GCS, R2, Vercel Blob) - Fixes client uploads ignoring document prefix (previously only server uploads respected `data.prefix`) - Adds centralized `getFileKey` utility for consistent path computation across adapters - Documents prefix behavior and composition ## Bug Fix Client uploads previously ignored document prefix entirely: ```typescript // Old generateSignedURL - only used collection prefix const prefix = collectionS3Config.prefix || '' const fileKey = path.posix.join(prefix, filename) ``` Now client and server uploads both use `getFileKey` with document prefix support. ## New Feature With `useCompositePrefixes: true`, prefixes combine instead of override: | Mode | Collection Prefix | Doc Prefix | Result | |------|------------------|------------|--------| | `false` (default) | `media-folder` | `user-123` | `user-123/file.jpg` | | `true` | `media-folder` | `user-123` | `media-folder/user-123/file.jpg` | ## Test plan - [x] Unit tests for `getFileKey` utility (12 tests) - [x] Integration tests verify composite prefix paths - [x] Client uploads now respect document prefix
Contributor
|
🚀 This is included in version v3.83.0 |
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.
Summary
useCompositePrefixesoption to all storage adapters (S3, Azure, GCS, R2, Vercel Blob)data.prefix)getFileKeyutility for consistent path computation across adaptersBug Fix
Client uploads previously ignored document prefix entirely:
Now client and server uploads both use
getFileKeywith document prefix support.New Feature
With
useCompositePrefixes: true, prefixes combine instead of override:false(default)media-folderuser-123user-123/file.jpgtruemedia-folderuser-123media-folder/user-123/file.jpgTest plan
getFileKeyutility (12 tests)