1

I have a functionality where I need the user to upload multiple files/images. The length of the requested files can be dynamic.

def add_images(image1: UploadFile = File(...),image2: UploadFile = File(...),image3: UploadFile = File(...)):
    return {"msg": "success"}

As of now, This is the body that I was requesting but I know this is not the ideal way.

1 Answer 1

1

You can upload multiple images by requesting the images as a List of UploadFile.

from typing import List

def add_images(images: List[UploadFile] = File(...)):
    // Your image upload code here
    return {"msg": "success"}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, @Dharmik, this solution worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.