Skip to content

Proposal: support lazy streaming multipart file binding #506

Description

@fpawel

Support lazy streaming multipart file binding

Summary

Following the discussion in go-swagger/go-swagger#3407, I would like to add opt-in lazy streaming support for multipart file parameters in go-openapi/runtime.

Today BindForm relies on http.Request.ParseMultipartForm, so the complete request body is consumed before the application handler receives the file.

The proposed server-side extension is parameter-level:

x-go-server-streaming: true

The runtime should expose the file payload lazily, while preserving the current buffered behavior by default.

Requirements

  • Support form fields before and after streamed files.
  • Support multiple file parts.
  • Avoid hidden background goroutines.
  • Define reader ownership, closing, draining, and error propagation.
  • Keep parameters requiring Seek, such as those with minLength or maxLength, on the buffered path.
  • Preserve compatibility with the existing BindForm behavior.

The reproducer, logs, prototype, and design discussion are available in:

go-swagger/go-swagger#3407

I have created a fork and would like to prepare the runtime design and implementation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions