View Source Anthropic.HTTPTransport.Multipart (anthropic_community v0.5.0)

Minimal multipart/form-data body encoder (RFC 7578) — just enough for file uploads (Anthropic.Files.create/2), not a general-purpose multipart library.

Summary

Functions

Encodes fields into a multipart body. A plain {name, value} tuple becomes a simple form field; {name, data, filename: ..., content_type: ...} becomes a file field.

Types

@type field() ::
  {name :: String.t(), value :: String.t()}
  | {name :: String.t(), data :: binary(), keyword()}

Functions

@spec encode([field()]) :: {boundary :: String.t(), iodata()}

Encodes fields into a multipart body. A plain {name, value} tuple becomes a simple form field; {name, data, filename: ..., content_type: ...} becomes a file field.

Returns {boundary, iodata} — the caller is responsible for setting the content-type: multipart/form-data; boundary=<boundary> request header.