Batch Upload into Media Folder

default discord avatar
Joekr
6 months ago
13

I am just setting up another instance of payload for a image-based dataset i wanna host. When just uploading my ~150 images into my media folder (which i have mounted inside my Media Collection) - they are not detected as media instances. Is there a nice way for such batch uploads, or do i really need to upload all images 1by1 to get them as Items inside the collection?

  • default discord avatar
    fewbar
    6 months ago

    As of now you cannot batch upload. You could write your own script that uses the Local API to create the media collection items one by one.

  • default discord avatar
    Mark | Omniux
    6 months ago

    Bulk uploading is part of the roadmap, stay tuned because it is an often asked for feature 🙂

  • default discord avatar
    Joekr
    6 months ago

    Is this something I can expect in the next week's?

  • discord user avatar
    zubricks
    Payload Team
    6 months ago

    Hey Joekr - we like to keep our launch week items under wraps until the week of, so you'll just have to stay tuned until then. Just know that Bulk operations are pretty high up on our list, so it shouldn't be too long now!

  • default discord avatar
    wiesson
    6 months ago

    I need this as well!

  • default discord avatar
    Panda
    5 months ago

    I just wanna chime in and say I need this as well haha

  • default discord avatar
    thisisnotchris
    5 months ago

    Until this feature is available, you can use the local API to upload files in bulk



    This assumes you have an express route that accepts multiple files



    But then you would follow the pattern of



    const media = await payload.create<Media>({
          collection: 'media',
          data: {
            alt: `alt text`,
          },
          file: <file buffer>,
    })


    In an array



    Once all of the promises have resolved, then you can set each uploaded item to a collection item



    Which is a payload.update call on whichever collection needs the uploaded file

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.