name 'File' is not define when used with FASTAPI

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?



from Recent Questions - Stack Overflow https://ift.tt/3f2zZNI
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation