1curl_mime_type(3)               libcurl Manual               curl_mime_type(3)
2
3
4

NAME

6       curl_mime_type - set a mime part's content type
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype);
12

DESCRIPTION

14       curl_mime_type(3) sets a mime part's content type.
15
16       part is the part's handle to assign the content type to.
17
18       mimetype points to the null-terminated file mime type string; it may be
19       set to NULL to remove a previously attached mime type.
20
21       The mime type string is copied into the part, thus the associated stor‐
22       age  may safely be released or reused after call. Setting a part's type
23       multiple times is valid: only the value set by the  last  call  is  re‐
24       tained.
25
26       In  the absence of a mime type and if needed by the protocol specifica‐
27       tions, a default mime type is determined by the context:
28       - If set as a custom header, use this value.
29       - application/form-data for an HTTP form post.
30       - If a remote file name is set, the mime type is taken  from  the  file
31       name extension, or application/octet-stream by default.
32       - For a multipart part, multipart/mixed.
33       - text/plain in other cases.
34

EXAMPLE

36        curl_mime *mime;
37        curl_mimepart *part;
38
39        /* create a mime handle */
40        mime = curl_mime_init(easy);
41
42        /* add a part */
43        part = curl_mime_addpart(mime);
44
45        /* get data from this file */
46        curl_mime_filedata(part, "image.png");
47
48        /* content-type for this part */
49        curl_mime_type(part, "image/png");
50
51        /* set name */
52        curl_mime_name(part, "image");
53

AVAILABILITY

55       As  long  as  at  least  one of HTTP, SMTP or IMAP is enabled. Added in
56       7.56.0.
57

RETURN VALUE

59       CURLE_OK or a CURL error code upon failure.
60

SEE ALSO

62       curl_mime_addpart(3), curl_mime_name(3), curl_mime_data(3)
63
64
65
66libcurl 7.85.0                   May 17, 2022                curl_mime_type(3)
Impressum