curl_mime_encoder.3 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, 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.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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_mime_encoder 3 "22 August 2017" "libcurl 7.56.0" "libcurl Manual"
  25. .SH NAME
  26. curl_mime_encoder - set a mime part's encoder and content transfer encoding
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding);
  31. .fi
  32. .SH DESCRIPTION
  33. curl_mime_encoder() requests a mime part's content to be encoded before being
  34. transmitted.
  35. \fIpart\fP is the part's handle to assign an encoder.
  36. \fIencoding\fP is a pointer to a null-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. Setting a part's encoder multiple times is valid: only the value set by the
  40. last call is retained.
  41. Upon multipart rendering, the part's content is encoded according to the
  42. pertaining scheme and a corresponding \fI"Content-Transfer-Encoding"\fP header
  43. is added to the part.
  44. Supported encoding schemes are:
  45. .br
  46. "\fIbinary\fP": the data is left unchanged, the header is added.
  47. .br
  48. "\fI8bit\fP": header added, no data change.
  49. .br
  50. "\fI7bit\fP": the data is unchanged, but is each byte is checked
  51. to be a 7-bit value; if not, a read error occurs.
  52. .br
  53. "\fIbase64\fP": Data is converted to base64 encoding, then split in
  54. CRLF-terminated lines of at most 76 characters.
  55. .br
  56. "\fIquoted-printable\fP": data is encoded in quoted printable lines of
  57. at most 76 characters. Since the resulting size of the final data cannot be
  58. determined prior to reading the original data, it is left as unknown, causing
  59. chunked transfer in HTTP. For the same reason, this encoder may not be used
  60. with IMAP. This encoder targets text data that is mostly ASCII and should
  61. not be used with other types of data.
  62. If the original data is already encoded in such a scheme, a custom
  63. \fIContent-Transfer-Encoding\fP header should be added with
  64. \fIcurl_mime_headers\fP() instead of setting a part encoder.
  65. Encoding should not be applied to multiparts, thus the use of this
  66. function on a part with content set with \fIcurl_mime_subparts\fP() is
  67. strongly discouraged.
  68. .SH EXAMPLE
  69. .nf
  70. curl_mime *mime;
  71. curl_mimepart *part;
  72. /* create a mime handle */
  73. mime = curl_mime_init(easy);
  74. /* add a part */
  75. part = curl_mime_addpart(mime);
  76. /* send a file */
  77. curl_mime_filedata(part, "image.png");
  78. /* encode file data in base64 for transfer */
  79. curl_mime_encoder(part, "base64");
  80. .fi
  81. .SH AVAILABILITY
  82. As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
  83. .SH RETURN VALUE
  84. CURLE_OK or a CURL error code upon failure.
  85. .SH "SEE ALSO"
  86. .BR curl_mime_addpart "(3),"
  87. .BR curl_mime_headers "(3),"
  88. .BR curl_mime_subparts "(3)"