Serializing upload files in Rich Text Field

default discord avatar
Mateusz Woskowicz
8 months ago
1

Hello!


I am using payload cms for my blog created in next.js. I have a problem downloading the image URL that I upload to AWS S3 in a Rich Text field.



The MongoDb query returns an object that contains the

id

of the image from the

media

table.



Currently, in the

serialize

component I created based on the docs on the frontend side sends a request to the api along with the id of the image, which returns me a

filename

from the media table.



Is there a simpler way to do this, to retrieve the

filename

immediately on the backend when querying to MongoDb?

  • discord user avatar
    dribbens
    Payload Team
    8 months ago

    You can use Payload's local API to get your data out and have relationships and uploads populated by the desired depth you need for your frontend. It sounds like you are maybe querying with mongo/mongoose directly and missing out on a big advantage of working with Payload.

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.