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.

Switching between s3 and local media files

default discord avatar
dragos.nedelcu2 years ago
5

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?

  • discord user avatar
    denolfe
    2 years 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
  • default discord avatar
    dragos.nedelcu2 years ago

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

  • discord user avatar
    denolfe
    2 years ago

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

  • default discord avatar
    miguderp2 years 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,
            },
        },
    }),
  • discord user avatar
    jmikrut
    2 years ago

    yep



    @157199103921618944

    that is the move

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.