base64 image in payloadcms

default discord avatar
kris0x
4 months ago
6

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
    Payload Team
    4 months 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
    kris0x
    4 months 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
    Payload Team
    4 months ago

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

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.