feat(plugin-cloud-storage): implement prefix option across all adapters#16213
Closed
JarrodMFlesch wants to merge 14 commits intomainfrom
Closed
feat(plugin-cloud-storage): implement prefix option across all adapters#16213JarrodMFlesch wants to merge 14 commits intomainfrom
JarrodMFlesch wants to merge 14 commits intomainfrom
Conversation
…zation Add utility function to normalize and join multiple prefix segments. Handles trailing slashes, empty values, and path traversal protection.
- Add prefix option to R2StorageOptions for base prefix across all files - Update handleUpload, handleDelete, handleMultiPartUpload to use joinPrefixes - Fix staticHandler to use getFilePrefix (dynamic lookup) instead of static prefix - Update initClientUploads to pass basePrefix to server handler
Add prefix option to GcsStorageOptions that prepends a base path to all file keys. Uses joinPrefixes utility to combine basePrefix with collection-level prefix. Updated all key-constructing functions: handleUpload, handleDelete, staticHandler, generateURL, and generateSignedURL.
- Add collections for testing basePrefix (MediaWithBasePrefix, MediaWithBasePrefixAndCollectionPrefix) - Add tests for upload with basePrefix only - Add tests for upload with basePrefix + collection prefix - Add tests for delete at basePrefix path - Add tests for delete at basePrefix + collection prefix path - Configure S3 storage with basePrefix option in test config
- Separate basePrefix collections into their own S3 adapter instance - Add cleanup for basePrefix upload tests to delete created documents
Add documentation for the new `prefix` option at the adapter level for all storage adapters. This includes: - Added `prefix` to configuration options tables for all adapters (Vercel Blob, S3, Azure, GCS, Uploadthing, R2) - Added Configuration Options table for R2 adapter (was missing) - Added `prefix` to Plugin options table for plugin-cloud-storage - Updated Collection-specific options `prefix` description to clarify how it combines with adapter-level prefix - Added new "Prefix Namespacing" section explaining: - How adapter-level and collection-level prefixes work together - Complete example showing prefix usage patterns - Use cases (multi-environment, multi-project, organizational namespacing)
…takes object
- Extract sanitizePrefix to shared utility
- joinPrefixes now takes { basePrefix, prefix } object
- Only sanitizes prefix (user-controlled), not basePrefix (config)
- All storage adapters updated to new signature
…o-storage-adapters # Conflicts: # packages/plugin-cloud-storage/src/utilities/getFilePrefix.ts # packages/storage-azure/src/staticHandler.ts # packages/storage-gcs/src/staticHandler.ts # packages/storage-r2/src/staticHandler.ts # packages/storage-vercel-blob/src/staticHandler.ts
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
…I with explicit sanitization
Contributor
Author
|
Closed in favor of #16230 |
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
Implements the existing
prefixoption across all storage adapters. While R2 already used this option for organizational namespacing (storing files under paths likemy-project/uploads/image.png), the other adapters (S3, GCS, Azure, Vercel Blob) weren't using it. This makes the feature functional across all storage adapters except Uploadthing, which doesn't support custom paths.The implementation extracts shared sanitization logic into a
sanitizePrefixutility and updatesjoinPrefixesto distinguish between config-controlled prefixes (trusted) and user-controlled prefixes (sanitized).