Skip to content

Comments

Document BlackSheep 2.6.0 multipart/form-data improvements#32

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-issue-with-blog-pagination
Draft

Document BlackSheep 2.6.0 multipart/form-data improvements#32
Copilot wants to merge 3 commits intomainfrom
copilot/fix-issue-with-blog-pagination

Conversation

Copy link

Copilot AI commented Feb 9, 2026

BlackSheep 2.6.0 introduced memory-efficient streaming for multipart/form-data with SpooledTemporaryFile-backed file handling, automatic resource cleanup, and full OpenAPI support for FromText and FromFiles binders.

Changes

requests.md

  • Streaming API: Documented Request.multipart_stream() for memory-efficient parsing without buffering entire request body
  • FileBuffer API: Complete API reference for read(), seek(), close(), async save_to()
  • Memory management: SpooledTemporaryFile behavior (<1MB in memory, >1MB spills to disk)
  • Resource cleanup: Automatic Request.dispose() invocation by framework
  • Mixed forms: Examples combining FromText and FromFiles

openapi.md

  • Request body binders: New section documenting automatic OpenAPI generation for FromJSON, FromForm, FromText, FromFiles
  • Multipart documentation: Examples showing how mixed text/file endpoints appear in OpenAPI specs

Example

Memory-efficient streaming for large uploads:

from blacksheep import post, Request, created

@post("/upload-large")
async def upload_large_files(request: Request):
    # Stream multipart data without buffering entire request body
    async for part in request.multipart_stream():
        if part.file_name:
            file_name = part.file_name.decode()
            with open(f"./uploads/{file_name}", "wb") as f:
                async for chunk in part.stream():
                    f.write(chunk)
    return created()

Screenshots

Requests documentation - File upload section
requests-file-upload

OpenAPI documentation - Request body binders
openapi-request-body-binders

Original prompt

Work on #31

Created from Copilot CLI via the copilot delegate command.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 9, 2026 20:18
Co-authored-by: RobertoPrevato <2576032+RobertoPrevato@users.noreply.github.com>
Co-authored-by: RobertoPrevato <2576032+RobertoPrevato@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with blog pagination in theme Document BlackSheep 2.6.0 multipart/form-data improvements Feb 9, 2026
Copilot AI requested a review from RobertoPrevato February 9, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants