---
title: "Discussion on \"Upload files in FastAPI with file validation\" | Hashnode"
description: "Discussion on \"Upload files in FastAPI with file validation\". File upload and validation can get tricky when it comes to FastAPI as we simply cannot use pydantic to do validations for us. Let's see how to get this done\nfrom fastapi import UploadFile\n\n@app.post(\"/file\")\ndef upload_file(file: UploadFile):\n    val..."
url: "https://hashnode.com/posts/upload-files-in-fastapi-with-file-validation/64fb08a2728f628582365ba7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Upload files in FastAPI with file validation](https://jayhawk24.hashnode.dev/upload-files-in-fastapi-with-file-validation?utm_source=hashnode&utm_medium=feed)

File upload and validation can get tricky when it comes to FastAPI as we simply cannot use pydantic to do validations for us. Let's see how to get this done from fastapi import UploadFile @app.post("/file") def upload\_file(file: UploadFile): val...

Sep 8, 2023 · 2 min read · jayhawk24.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#fastapi](https://hashnode.com/tag/fastapi)
-   [#file-upload](https://hashnode.com/tag/file-upload)
-   [#github](https://hashnode.com/tag/github)
-   [#backend](https://hashnode.com/tag/backend)

## Written by

[Anubhav Gupta](https://hashnode.com/@jayhawk24)

@jayhawk24

  
[View profile](https://hashnode.com/@jayhawk24)

✈️Travelaholic. 🐱💻 WebDev fanatic. Hardcore hacker.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
