You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`enabled`| Whether or not to enable the plugin |`true`|
134
+
|`collections`| Collections to apply the S3 adapter to ||
135
+
|`bucket`| The name of the S3 bucket ||
136
+
|`config`|`S3ClientConfig` object passed to the AWS SDK client ||
137
+
|`acl`| Access control list for uploaded files (e.g. `'public-read'`) |`undefined`|
138
+
|`clientUploads`| Do uploads directly on the client to bypass Vercel's 4.5MB server limit ||
139
+
|`signedDownloads`| Use presigned URLs for file downloads. Can be overridden per collection ||
140
+
|`useCompositePrefixes`| Combine collection prefix with document prefix instead of document prefix overriding it. |`false`|
139
141
140
142
For full `S3ClientConfig` options, see the [AWS SDK Package](https://github.com/aws/aws-sdk-js-v3) and [`S3ClientConfig`](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3) docs.
|`enabled`| Whether or not to enable the plugin |`true`|
305
+
|`collections`| Collections to apply the storage to ||
306
+
|`bucket`| The name of the bucket to use ||
307
+
|`options`| Google Cloud Storage client configuration. See [Docs](https://github.com/googleapis/nodejs-storage)||
308
+
|`acl`| Access control list for files that are uploaded |`Private`|
309
+
|`clientUploads`| Do uploads directly on the client to bypass limits on Vercel. ||
310
+
|`useCompositePrefixes`| Combine collection prefix with document prefix instead of document prefix overriding it. |`false`|
307
311
308
312
## Uploadthing Storage
309
313
@@ -456,6 +460,44 @@ This plugin is configurable to work across many different Payload collections. A
456
460
|`generateFileURL`|[GenerateFileURL](https://github.com/payloadcms/payload/blob/main/packages/plugin-cloud-storage/src/types.ts#L67)| Override the generated file URL with one that you create. |
457
461
|`prefix`|`string`| Set to `media/images` to upload files inside `media/images` folder in the bucket. |
458
462
463
+
## Prefix Composition
464
+
465
+
Storage adapters support two types of prefixes:
466
+
467
+
-**Collection prefix**: Set at the adapter configuration level (e.g., `prefix: 'media-folder'`)
468
+
-**Document prefix**: Set per-document via the `prefix` field on the upload collection
469
+
470
+
By default, if a document has a prefix, it **overrides** the collection prefix entirely.
471
+
472
+
With `useCompositePrefixes: true`, the prefixes are **combined**:
473
+
474
+
```
475
+
# Without useCompositePrefixes (default)
476
+
Collection prefix: media-folder
477
+
Document prefix: user-123
478
+
Result: user-123/image.jpg
479
+
480
+
# With useCompositePrefixes: true
481
+
Collection prefix: media-folder
482
+
Document prefix: user-123
483
+
Result: media-folder/user-123/image.jpg
484
+
```
485
+
486
+
This is useful when you want a base folder structure (collection prefix) while still allowing per-document organization (document prefix).
487
+
488
+
```ts
489
+
s3Storage({
490
+
collections: {
491
+
media: {
492
+
prefix: 'uploads', // All files go under uploads/
493
+
},
494
+
},
495
+
useCompositePrefixes: true, // Document prefixes append to collection prefix
496
+
bucket: process.env.S3_BUCKET,
497
+
// ...
498
+
})
499
+
```
500
+
459
501
## Payload Access Control
460
502
461
503
Payload ships with [Access Control](../access-control/overview) that runs _even on statically served files_. The same `read` Access Control property on your `upload`-enabled collections is used, and it allows you to restrict who can request your uploaded files.
0 commit comments