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

AVAILABILITY

35       As long as at least one of HTTP, SMTP or  IMAP  is  enabled.  Added  in
36       7.56.0.
37

RETURN VALUE

39       CURLE_OK or a CURL error code upon failure.
40

EXAMPLE

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

SEE ALSO

61       curl_mime_addpart(3), curl_mime_name(3), curl_mime_data(3)
62
63
64
65libcurl 7.76.1                 November 04, 2020             curl_mime_type(3)
Impressum