The following function should output the file size of the image when sending a Post request from Insomnia/Postman API development environments.
@app.post("/user/photo") async def upload_user_photo(response: Response, profile_photo: bytes = File(...)): response.headers["x-file-size"] = str(len(profile_photo)) response.set_cookie(key="cookie-api", value="test") return {"file size": len(profile_photo)} However the following error occurs:
File ".\run.py", line 54, in <module> async def upload_user_photo(response: Response, profile_photo: bytes = File(...)): NameError: name 'File' is not defined I've read that File() has been depreciated from Python 3, so what would be a way to get this to work?