Skip to content
Discussion options

You must be logged in to vote

@guzman109 you need to replace files_extra: Annotated[list[UploadFile] | None, File(description="Optional Extra Files")] = None to files_extra: Annotated[List[UploadFile], File(description="Optional Extra Files")] = [] because the combination of List[UploadFile] | None with File(...) creates a conflict. FastAPI expects a required file list due to File(...), but if it receives None (as might be the case when files are not provided), it leads to processing issues.

files = [
   ( "file_a", ("file_a.txt", open("file_a.txt", "rb"), "text/plain") ),
   ( "file_b", ("file_b.txt", open("file_b.txt", "rb"), "text/plain") )
-  [
+ # Each 'files_extra' is treated as a separate tuple, but they all sh…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@guzman109
Comment options

Answer selected by guzman109
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants