curl_mime_encoder.3 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .\" generated by cd2nroff 0.1 from curl_mime_encoder.md
  2. .TH curl_mime_encoder 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_mime_encoder \- set a mime part\(aqs encoder and content transfer encoding
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding);
  9. .fi
  10. .SH DESCRIPTION
  11. curl_mime_encoder() requests a mime part\(aqs content to be encoded before being
  12. transmitted.
  13. \fIpart\fP is the part\(aqs handle to assign an encoder.
  14. \fIencoding\fP is a pointer to a null\-terminated encoding scheme. It may be
  15. set to NULL to disable an encoder previously attached to the part. The encoding
  16. scheme storage may safely be reused after this function returns.
  17. Setting a part\(aqs encoder multiple times is valid: only the value set by the
  18. last call is retained.
  19. Upon multipart rendering, the part\(aqs content is encoded according to the
  20. pertaining scheme and a corresponding \fI"Content\-Transfer\-Encoding"\fP header
  21. is added to the part.
  22. Supported encoding schemes are:
  23. \&"\fIbinary\fP": the data is left unchanged, the header is added.
  24. \&"\fI8bit\fP": header added, no data change.
  25. \&"\fI7bit\fP": the data is unchanged, but is each byte is checked
  26. to be a 7\-bit value; if not, a read error occurs.
  27. \&"\fIbase64\fP": Data is converted to base64 encoding, then split in
  28. CRLF\-terminated lines of at most 76 characters.
  29. \&"\fIquoted\-printable\fP": data is encoded in quoted printable lines of
  30. at most 76 characters. Since the resulting size of the final data cannot be
  31. determined prior to reading the original data, it is left as unknown, causing
  32. chunked transfer in HTTP. For the same reason, this encoder may not be used
  33. with IMAP. This encoder targets text data that is mostly ASCII and should
  34. not be used with other types of data.
  35. If the original data is already encoded in such a scheme, a custom
  36. \fIContent\-Transfer\-Encoding\fP header should be added with
  37. \fIcurl_mime_headers(3)\fP instead of setting a part encoder.
  38. Encoding should not be applied to multiparts, thus the use of this function on
  39. a part with content set with \fIcurl_mime_subparts(3)\fP is strongly
  40. discouraged.
  41. .SH PROTOCOLS
  42. This functionality affects http, imap and smtp
  43. .SH EXAMPLE
  44. .nf
  45. int main(void)
  46. {
  47. curl_mime *mime;
  48. curl_mimepart *part;
  49. CURL *curl = curl_easy_init();
  50. if(curl) {
  51. /* create a mime handle */
  52. mime = curl_mime_init(curl);
  53. /* add a part */
  54. part = curl_mime_addpart(mime);
  55. /* send a file */
  56. curl_mime_filedata(part, "image.png");
  57. /* encode file data in base64 for transfer */
  58. curl_mime_encoder(part, "base64");
  59. }
  60. }
  61. .fi
  62. .SH AVAILABILITY
  63. Added in curl 7.56.0
  64. .SH RETURN VALUE
  65. CURLE_OK or a CURL error code upon failure.
  66. .SH SEE ALSO
  67. .BR curl_mime_addpart (3),
  68. .BR curl_mime_headers (3),
  69. .BR curl_mime_subparts (3)