C. file.read() should be awaited in async function
D. Endpoint function must be async to await file.read()
Solution
Step 1: Check imports and function signature
The code misses importing File and the function is not async but calls file.read() which is async.
Step 2: Identify async usage and await
To read file content, function must be async and use await file.read().
Final Answer:
All of the above -> Option B
Quick Check:
Missing import, async, and await cause errors [OK]
Hint: Import File, make function async, await file.read() [OK]
Common Mistakes:
Forgetting to import File
Using sync function with async file.read()
Not awaiting file.read()
5. You want to create a FastAPI endpoint that accepts a single file upload and returns the file's name, content type, and first 10 bytes as a UTF-8 string. Which code snippet correctly implements this?