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.
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"}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.