'How to post multiple images to mastodon using api with bash curl

I'm starting to learn to use rest api via bash curl by writing a simple mastodon bot. I can attach multiple images using

curl https://example.com/api/v1/statuses \
                   -H 'Authorization: Bearer $TOKEN' \
                   -F "status=text" \
                   -F "media_ids[]=$id1" \
                   -F "media_ids[]=$id2" \
                   -F "media_ids[]=$id3"

But how to attach multiple pictures, when I don't know, how many filenames will be passed to the script? Documentation says, I should pass an array of ids. What is the right way to do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source