Hey everyone! I'm working on a PayloadCMS project and need some advice on setting up file storage. For local development, I want to use a Minio S3 instance to handle uploads, but when deploying to Payload Cloud, I’d like it to switch seamlessly to the S3 storage provided by the platform.
My goal is to configure payload.config.js and environment variables so that it works with Minio locally (using access/secret keys and a custom endpoint) and then uses Payload Cloud’s S3 (with Cognito auth, I assume?) in production without breaking anything. Has anyone set this up before? What’s the best way to handle the conditional logic for switching between the two environments? Any tips or examples would be super helpful! Thanks!
All plugins have an
enabledswitch.
Here one my configs. (I do not use a storage provider in dev)
s3Storage({
enabled: process.env.S3_ENABLED === 'true',
collections: {
media: true,You could use a
STORAGE_PROVIDERvariable to switch between your providers.
Very helpful, thank you!
While examining templates and code examples in other repositories, I couldn’t find any instances of working with the S3 storage from Payload Cloud or its specific configurations. Does this mean that for local development, it’s sufficient to have the
@payloadcms/payload-cloudplugin connected, which will use the local file system as storage, and then, when deployed to production in Payload Cloud, a storage solution will be automatically set up to store all media files? Initially, I assumed I’d need to set up a local S3 instance and manage the storage connection through variables in Payload Cloud.
PayloadCMS falls back to local storage.
https://payloadcms.com/docs/upload/storage-adaptersI have not used Payload Cloud, yet.
But setup should not be different from others.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.