Skip to content

httprequest: support []gomultipart.File for multiple file uploads #108

@djthorpe

Description

@djthorpe

Summary

httprequest.Read currently supports only a single gomultipart.File field per struct field name in multipart/form-data requests. It would be useful to support []gomultipart.File to allow multiple file uploads for the same field.

Current Behaviour

In pkg/httprequest/read.go, readFormData only handles typeFile (gomultipart.File) in the type switch and only accesses values[0] from the multipart file headers. A []gomultipart.File field falls through to the default case and returns a bad-request error.

Proposed Change

Decoding (pkg/httprequest/read.go):

  • Add typeFileSlice = reflect.TypeOf([]gomultipart.File{})
  • Add a case typeFileSlice: branch that iterates all file headers and builds a []gomultipart.File slice

Encoding (go-client pkg/multipart):

  • Add slice handling in Encode to iterate []gomultipart.File elements and write each with the same field name

Use Case

HTTP handlers that accept requests with multiple file attachments (e.g. an LLM ask endpoint that can receive multiple images/documents alongside a text prompt).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions