Bird
0
0

Which of the following is the correct syntax to declare a FastAPI endpoint that accepts multiple files named 'files'?

easy📝 Syntax Q12 of 15
FastAPI - File Handling
Which of the following is the correct syntax to declare a FastAPI endpoint that accepts multiple files named 'files'?
Afiles: List[UploadFile] = File(...)
Bfiles: UploadFile = File(...)
Cfiles: List[str] = File(...)
Dfiles: str = UploadFile(...)
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter type for multiple files

    Multiple files require List[UploadFile] type hint.
  2. Step 2: Use File(...) to mark as file input

    File(...) is needed to tell FastAPI this is a file upload field.
  3. Final Answer:

    files: List[UploadFile] = File(...) -> Option A
  4. Quick Check:

    Multiple files syntax = List[UploadFile] = File(...) [OK]
Quick Trick: Use List[UploadFile] = File(...) for multiple files param [OK]
Common Mistakes:
MISTAKES
  • Using UploadFile without List for multiple files
  • Using List[str] which is incorrect for files
  • Assigning UploadFile(...) instead of File(...)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FastAPI Quizzes