Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Configuring multiple S3 Buckets

default discord avatar
alejotoro_o6 months ago
2

Hi, I have an app that already uses one S3 bucket using the S3 plugin. However, i need to configure another one for a new collection. Right now my config is as follows:



plugins: [


...plugins,


s3Storage({


enabled: process.env.S3_STORAGE === 'true',


collections: {


media: true, // Apply storage to 'media' collection


},


bucket: process.env.S3_BUCKET

'',
config: {
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID

'',


secretAccessKey: process.env.S3_SECRET

'',
},
region: 'auto', // Cloudflare R2 uses 'auto' as the region
endpoint: process.env.S3_ENDPOINT

'',


},


}),


],



If i want to define another bucket, do I just simply create another instance of s3Storage, or is there a more appropriate way?

  • default discord avatar
    anders22926 months ago

    Yes, if you want it to go to different buckets you create another instance of the s3storage plugin.



    Note that there was a recent bug with how multiple storage plugins shared the cache. So make sure you are at version 3.62.0 or newer.



    Ref:

    https://github.com/payloadcms/payload/pull/14267
  • default discord avatar
    alejotoro_o6 months ago

    Thanks

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.