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       twice is valid: only the value set by the last call is retained.
24
25       In the absence of a mime type and if needed by the protocol  specifica‐
26       tions, a default mime type is determined by the context:
27       - If set as a custom header, use this value.
28       - application/form-data for an HTTP form post.
29       -  If  a  remote file name is set, the mime type is taken from the file
30       name extension, or application/octet-stream by default.
31       - For a multipart part, multipart/mixed.
32       - text/plain in other cases.
33

EXAMPLE

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

AVAILABILITY

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

RETURN VALUE

58       CURLE_OK or a CURL error code upon failure.
59

SEE ALSO

61       curl_mime_addpart(3), curl_mime_name(3), curl_mime_data(3)
62
63
64
65libcurl 7.82.0                 November 26, 2021             curl_mime_type(3)
Impressum