Skip to content

Feat/file uploads - #82

Merged
NEFORCEO merged 20 commits into
masterfrom
feat/file-uploads
Jun 22, 2026
Merged

Feat/file uploads#82
NEFORCEO merged 20 commits into
masterfrom
feat/file-uploads

Conversation

@NEFORCEO

Copy link
Copy Markdown
Member

🚀 Description

Added file upload support (files=) at the decorator level and in the Route model. Files can now be uploaded via @app.post(files=...), @app.put(files=...), etc. Implemented by passing the files parameter through to httpx.AsyncClient.request().


🧩 Type of Change

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation update
  • refactor: Code refactoring
  • ci: CI/CD changes
  • chore: Maintenance

✅ Checklist

  • Tests added or updated
  • Documentation updated
  • No breaking changes
  • Code follows project style

🔗 Related Issues


📸 Additional Context

Changed Files

Code:

  • fasthttp/types.py — added FileContent, FileTuple, FileUpload types
  • fasthttp/routing.pyfiles field in Route, _RouteDef; files= parameter in all Router decorators
  • fasthttp/app.pyfiles= parameter in all FastHTTP decorators
  • fasthttp/client.pyfiles=route.files in httpx.AsyncClient.request()

Documentation:

  • docs/en/tutorial/file-uploads.md — new page (EN)
  • docs/ru/tutorial/file-uploads.md — new page (RU)
  • docs/en/tutorial/http-methods.md — added files row to decorator parameters table
  • docs/ru/tutorial/http-methods.md — added decorator parameters table with files
  • docs/en/tutorial/request-parameters.md — added "File Uploads" section
  • docs/ru/tutorial/request-parameters.md — added "Загрузка файлов" section
  • mkdocs.yml — added new pages to navigation

Examples:

  • examples/files/ — 8 examples (simple, tuple, multiple, list, json+files, path, file object, router)

Usage

from fasthttp import FastHTTP
from fasthttp.response import Response

app = FastHTTP()

@app.post(
    url="https://httpbin.org/post",
    files={"file": ("report.csv", b"name,score\nAlice,95\n", "text/csv")},
)
async def upload(resp: Response) -> dict:
    return resp.json()

app.run()

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for your contribution, @NEFORCEO!

Please make sure:

  • Code is clean and formatted
  • Tests are passing
  • PR description is clear

Maintainers will review it soon.

@codspeed-hq

codspeed-hq Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 42.4%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 6 improved benchmarks
✅ 6 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_response_req_text_from_json 213.2 µs 134.4 µs +58.59%
test_response_repr 196.4 µs 131.6 µs +49.26%
test_response_property_access 194.5 µs 131.3 µs +48.11%
test_response_json_parsing 205.6 µs 140.9 µs +45.94%
test_response_creation 201.3 µs 139.9 µs +43.85%
test_middleware_after_response 403.1 µs 355.9 µs +13.26%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/file-uploads (98989f7) with master (6f3d441)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (d5f813e) during the generation of this report, so 6f3d441 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@NEFORCEO
NEFORCEO merged commit 8347d0b into master Jun 22, 2026
17 checks passed
@NEFORCEO
NEFORCEO deleted the feat/file-uploads branch June 22, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants