Like what we’re doing? Star us on GitHub!

Switching between s3 and local media files

dragos.nedelcu
last month
6

hey 👋 I am currently using plugin-cloud-storage and searched for an answer in docs, issues and here, but can't find a solution to switch on using local media files when I am working on my local machine. Did anyone solved this?

  • denolfe
    Payload Team
    3 weeks ago

    The easiest way to do this would be to have an environment variables that is referenced inside your payload config, then conditionally use the plugin. Something similar can be seen here:

    https://github.com/payloadcms/plugin-cloud-storage/blob/master/dev/src/payload.config.ts
  • dragos.nedelcu
    3 weeks ago

    tried that, unfortunately it doesn't work 😦 ended up using minio to replicate s3 on my local machine. It works okay like that.

  • denolfe
    Payload Team
    3 weeks ago

    Interesting, I don't see any reason why that wouldn't work. Glad you were able to find a solution 👍

  • Migu
    3 weeks ago

    We managed to have S3 on production and local files on dev simply with this; basically it’ll send an empty object on dev so the plugin doesn’t throw an error



    cloudStorage({
        collections: process.env.NODE_ENV !== 'development' && {
            media: {
                adapter,
            },
        },
    }),
  • jmikrut
    Payload Team
    3 weeks ago

    yep



    @Migu that is the move

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More