| 1 |
.\" ************************************************************************** |
| 2 |
.\" * _ _ ____ _ |
| 3 |
.\" * Project ___| | | | _ \| | |
| 4 |
.\" * / __| | | | |_) | | |
| 5 |
.\" * | (__| |_| | _ <| |___ |
| 6 |
.\" * \___|\___/|_| \_\_____| |
| 7 |
.\" * |
| 8 |
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <[email protected]>, et al. |
| 9 |
.\" * |
| 10 |
.\" * This software is licensed as described in the file COPYING, which |
| 11 |
.\" * you should have received as part of this distribution. The terms |
| 12 |
.\" * are also available at https://curl.haxx.se/docs/copyright.html. |
| 13 |
.\" * |
| 14 |
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 15 |
.\" * copies of the Software, and permit persons to whom the Software is |
| 16 |
.\" * furnished to do so, under the terms of the COPYING file. |
| 17 |
.\" * |
| 18 |
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 |
.\" * KIND, either express or implied. |
| 20 |
.\" * |
| 21 |
.\" ************************************************************************** |
| 22 |
.TH curl_mime_encoder 3 "22 August 2017" "libcurl 7.56.0" "libcurl Manual" |
| 23 |
.SH NAME |
| 24 |
curl_mime_encoder - set a mime part's encoder and content transfer encoding |
| 25 |
.SH SYNOPSIS |
| 26 |
.B #include <curl/curl.h> |
| 27 |
.sp |
| 28 |
.BI "CURLcode curl_mime_encoder(curl_mimepart * " part , |
| 29 |
.BI "const char * " encoding ");" |
| 30 |
.ad |
| 31 |
.SH DESCRIPTION |
| 32 |
curl_mime_encoder() requests a mime part's content to be encoded before being |
| 33 |
transmitted. |
| 34 |
|
| 35 |
\fIpart\fP is the part's handle to assign an encoder. |
| 36 |
\fIencoding\fP is a pointer to a zero-terminated encoding scheme. It may be |
| 37 |
set to NULL to disable an encoder previously attached to the part. The encoding |
| 38 |
scheme storage may safely be reused after this function returns. |
| 39 |
|
| 40 |
Setting a part's encoder twice is valid: only the value set by the last call is |
| 41 |
retained. |
| 42 |
|
| 43 |
Upon multipart rendering, the part's content is encoded according to the |
| 44 |
pertaining scheme and a corresponding \fIContent-Transfer-Encoding"\fP header |
| 45 |
is added to the part. |
| 46 |
|
| 47 |
Supported encoding schemes are: |
| 48 |
.br |
| 49 |
"\fIbinary\fP": the data is left unchanged, the header is added. |
| 50 |
.br |
| 51 |
"\fI8bit\fP": header added, no data change. |
| 52 |
.br |
| 53 |
"\fI7bit\fP": the data is unchanged, but is each byte is checked |
| 54 |
to be a 7-bit value; if not, a read error occurs. |
| 55 |
.br |
| 56 |
"\fIbase64\fP": Data is converted to base64 encoding, then split in |
| 57 |
CRLF-terminated lines of at most 76 characters. |
| 58 |
.br |
| 59 |
"\fIquoted-printable\fP": data is encoded in quoted printable lines of |
| 60 |
at most 76 characters. Since the resulting size of the final data cannot be |
| 61 |
determined prior to reading the original data, it is left as unknown, causing |
| 62 |
chunked transfer in HTTP. For the same reason, this encoder may not be used |
| 63 |
with IMAP. This encoder targets text data that is mostly ASCII and should |
| 64 |
not be used with other types of data. |
| 65 |
|
| 66 |
If the original data is already encoded in such a scheme, a custom |
| 67 |
\fIContent-Transfer-Encoding\fP header should be added with |
| 68 |
\FIcurl_mime_headers\fP() instead of setting a part encoder. |
| 69 |
|
| 70 |
Encoding should not be applied to multiparts, thus the use of this |
| 71 |
function on a part with content set with \fIcurl_mime_subparts\fP() is |
| 72 |
strongly discouraged. |
| 73 |
.SH AVAILABILITY |
| 74 |
As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. |
| 75 |
.SH RETURN VALUE |
| 76 |
CURLE_OK or a CURL error code upon failure. |
| 77 |
.SH EXAMPLE |
| 78 |
.nf |
| 79 |
curl_mime *mime; |
| 80 |
curl_mimepart *part; |
| 81 |
|
| 82 |
/* create a mime handle */ |
| 83 |
mime = curl_mime_init(easy); |
| 84 |
|
| 85 |
/* add a part */ |
| 86 |
part = curl_mime_addpart(mime); |
| 87 |
|
| 88 |
/* send a file */ |
| 89 |
curl_mime_filedata(part, "image.png"); |
| 90 |
|
| 91 |
/* encode file data in base64 for transfer */ |
| 92 |
curl_mime_encoder(part, "base64"); |
| 93 |
.fi |
| 94 |
.SH "SEE ALSO" |
| 95 |
.BR curl_mime_addpart "(3)," |
| 96 |
.BR curl_mime_headers "(3)," |
| 97 |
.BR curl_mime_subparts "(3)" |