Serve a list of S3 stored images

I am a newb to Elixir and Phoenix. I have a usecase where I query my DB and get a list of about 5k S3 URLs . The response should be a JSON list of either the binary file or a base64 encoded.
I am using ExAWS.S3.get_object but this is taking too long(in my opinion). I was thinking to use Task.async_stream but I am not sure how to aggregate the responses from the async calls and returning them as the response JSON.

Would appreciate any help.

list_of_urls
|> Task.async_stream(&YourModule.your_function/1)
|> Enum.to_list() # <- you could probably do without this but too lazy to check now
|> Jason.encode!()

…would be my first try. Where YourModule.your_function contains code that transforms the URL to a singular JSON object with the file’s contents encoded inside it in the way you need it.