Skip to content

MIME Handle Reference

Qriist edited this page Sep 17, 2026 · 1 revision

The mime_handle manages multipart form encoding, allowing complex uploads where each field carries its own name, content, and type. This reference lists the core methods which operate on a mime_handle or mime_part, their primary function, and links to the official libcurl documentation.

Lifecycle

Method Description libcurl Reference
MimeInit(easy_handle?) Creates a MIME handle associated with an easy handle. curl_mime_init
MimeCleanup(mime_handle?) Releases the MIME handle and all associated parts. curl_mime_free

Part Management

Method Description libcurl Reference
MimeAddPart(mime_handle?) Initializes a new MIME part. curl_mime_addpart
AttachMimePart(partName, partContent, mime_handle?) Creates a part, assigns its name, auto-detects type, and attaches content. curl_mime_addpart
AttachMimeAsPart(partName, mime_to_embed, mime_handle?) Embeds an entire MIME handle as a nested part. curl_mime_subparts

Part Configuration

Method Description libcurl Reference
MimePartName(mime_part, partName) Assigns the field name to a MIME part. curl_mime_name
MimePartData(mime_part, partContent) Attaches String, Object, Map, Buffer, or File content. curl_mime_data
MimePartType(mime_part, partContent?, override?) Sets or auto-detects the MIME type. curl_mime_type
MimePartEncoder(mime_part, encoding := "") Configures an encoder for the part. curl_mime_encoder
MimeTreatPartAsFile(mime_part, filename := "") Instructs the server to treat the part as a file. curl_mime_filename
SetMimePartHeaders(mime_part, headersObject) Sets custom HTTP headers for a specific part. curl_mime_headers

Utility

Method Description libcurl Reference
GetMimeType(sourceData) Returns the detected MIME type for a given source. —

Where to Go Next

Clone this wiki locally