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.

base64 image in payloadcms

default discord avatar
kris0x2 years ago
3

Is it possible to have image upload field, but instead of storing image as a file, I'd like to convert it to base64 encoded string and put it directly to the MongoDB.



How should one go about this ?

  • discord user avatar
    denolfe
    2 years ago

    Storing images as base64 in the DB is not currently supported. Feel free to submit a feature request, so we can discuss/prioritize with everyone.



    https://github.com/payloadcms/payload/discussions

    I'm not sure on the appetite of a feature like that getting into Payload core



    It's likely possible to implement an adapter for

    https://github.com/payloadcms/plugin-cloud-storage

    depending on your skillset.

  • default discord avatar
    kris0x2 years ago

    We just store it as string.. right now we ask the customer to convert manually and paste the string 😅😆 that should work right



    I was thinking then of just creating a custom component that will handle the "upload* and conversion to b64

  • discord user avatar
    denolfe
    2 years ago

    Yes, as long as you handle the conversion on your own 👍

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.