Encodes multipart/form-data requests for Discord file uploads.
Produces iodata bodies with a payload_json part and indexed files[n] parts.
Automatically injects the attachments array into the JSON payload.
Summary
Functions
Encodes a JSON payload and files into multipart/form-data.
Escapes a filename for use in Content-Disposition headers.
Returns the MIME type for a filename based on its extension.
Functions
@spec encode(map(), [EDA.File.t()]) :: {iodata(), String.t()}
Encodes a JSON payload and files into multipart/form-data.
Returns {body_iodata, content_type} where content_type includes the boundary.
The attachments array is automatically injected into the JSON payload
with id matching the file index, filename, and optional description.
Escapes a filename for use in Content-Disposition headers.
Escapes backslashes, double quotes, and replaces newlines with underscores.
Returns the MIME type for a filename based on its extension.
Falls back to application/octet-stream for unknown extensions.