FastAPI - File Handling
Examine this FastAPI code snippet for background file saving:
What is the main issue with this implementation?
async def save_file(file: UploadFile):
content = await file.read()
with open(file.filename, "wb") as f:
f.write(content)
@app.post("/upload")
async def upload(file: UploadFile, background_tasks: BackgroundTasks):
background_tasks.add_task(save_file, file)
return {"message": "Upload started"}What is the main issue with this implementation?
