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