Bird
0
0

What will be the response content type when a FastAPI endpoint returns the filename of an uploaded file received as UploadFile?

medium📝 component behavior Q4 of 15
FastAPI - File Handling
What will be the response content type when a FastAPI endpoint returns the filename of an uploaded file received as UploadFile?
Aapplication/json
Btext/plain
Capplication/octet-stream
Dmultipart/form-data
Step-by-Step Solution
Solution:
  1. Step 1: Understand FastAPI default response type

    FastAPI returns application/json by default for dict or JSON responses.
  2. Step 2: Returning filename as string

    Returning the filename as a string will be sent as text/plain, but returning a dict with filename key returns application/json.
  3. Final Answer:

    application/json -> Option A
  4. Quick Check:

    Response content type for dict response = B [OK]
Quick Trick: FastAPI returns application/json by default for dict responses [OK]
Common Mistakes:
MISTAKES
  • Expecting text/plain for dict response
  • Confusing multipart/form-data with response type
  • Assuming application/octet-stream for filename string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FastAPI Quizzes