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.

Batch Upload into Media Folder

default discord avatar
joekr2 years ago
7

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
    phewbar2 years 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
    markatomniux2 years ago

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

  • default discord avatar
    joekr2 years ago

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

  • discord user avatar
    seanzubrickas
    2 years 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
    wiesson2 years ago

    I need this as well!

  • default discord avatar
    pandazaar2 years ago

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

  • default discord avatar
    notchr2 years 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

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.