1curl_mime_encoder(3) libcurl Manual curl_mime_encoder(3)
2
3
4
6 curl_mime_encoder - set a mime part's encoder and content transfer en‐
7 coding
8
10 #include <curl/curl.h>
11
12 CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding);
13
15 curl_mime_encoder() requests a mime part's content to be encoded before
16 being transmitted.
17
18 part is the part's handle to assign an encoder. encoding is a pointer
19 to a null-terminated encoding scheme. It may be set to NULL to disable
20 an encoder previously attached to the part. The encoding scheme storage
21 may safely be reused after this function returns.
22
23 Setting a part's encoder multiple times is valid: only the value set by
24 the last call is retained.
25
26 Upon multipart rendering, the part's content is encoded according to
27 the pertaining scheme and a corresponding "Content-Transfer-Encoding"
28 header is added to the part.
29
30 Supported encoding schemes are:
31 "binary": the data is left unchanged, the header is added.
32 "8bit": header added, no data change.
33 "7bit": the data is unchanged, but is each byte is checked to be a
34 7-bit value; if not, a read error occurs.
35 "base64": Data is converted to base64 encoding, then split in CRLF-ter‐
36 minated lines of at most 76 characters.
37 "quoted-printable": data is encoded in quoted printable lines of at
38 most 76 characters. Since the resulting size of the final data cannot
39 be determined prior to reading the original data, it is left as un‐
40 known, causing chunked transfer in HTTP. For the same reason, this en‐
41 coder may not be used with IMAP. This encoder targets text data that is
42 mostly ASCII and should not be used with other types of data.
43
44 If the original data is already encoded in such a scheme, a custom Con‐
45 tent-Transfer-Encoding header should be added with curl_mime_headers()
46 instead of setting a part encoder.
47
48 Encoding should not be applied to multiparts, thus the use of this
49 function on a part with content set with curl_mime_subparts() is
50 strongly discouraged.
51
53 curl_mime *mime;
54 curl_mimepart *part;
55
56 /* create a mime handle */
57 mime = curl_mime_init(easy);
58
59 /* add a part */
60 part = curl_mime_addpart(mime);
61
62 /* send a file */
63 curl_mime_filedata(part, "image.png");
64
65 /* encode file data in base64 for transfer */
66 curl_mime_encoder(part, "base64");
67
69 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in
70 7.56.0.
71
73 CURLE_OK or a CURL error code upon failure.
74
76 curl_mime_addpart(3), curl_mime_headers(3), curl_mime_subparts(3)
77
78
79
80libcurl 7.85.0 May 17, 2022 curl_mime_encoder(3)