Fastapi: How to inform file extension and file type to when uploading File

Created on 28 Mar 2019  路  3Comments  路  Source: tiangolo/fastapi

I would like to inform the file extension and file type to the OpenAPI.

E.g.:
Content-Disposition: form-data; name="fileName"; filename="*.txt"
Content-Type: text/plain

How can I do it using:

file: UploadFile = File(..., ???)

Thanks in advance

question

All 3 comments

Right now, as this is not currently tightly integrated, the way to do it would be to modify the generated OpenAPI: https://fastapi.tiangolo.com/tutorial/extending-openapi/

I'll assume you were able to solve your use case, so I'll close this issue now. But feel free to add more comments or create new issues.

Current link: https://fastapi.tiangolo.com/advanced/extending-openapi/
FastAPI version: 0.60.1

Was this page helpful?
0 / 5 - 0 ratings