Import images from API and attach to a field

default discord avatar
christopher.nowlan
last month
2

Is there a way to import images from an API and attach to a field

  • discord user avatar
    denolfe
    Payload Team
    last month

    From an external API? If you can get the file in the form of a file on disk or file buffer, yes this is possible.



    Here is an example of how to upload from disk using the local API:

    https://github.com/payloadcms/payload/blob/master/test/uploads/config.ts#L162

    You'd need a media collection to upload to, then a relationship field on a separate collection with

    relationTo: 'mediaSlug'
  • default discord avatar
    christopher.nowlan
    last month

    Thanks. I had figure it out

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.