curl_mime_data.3 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. .\" generated by cd2nroff 0.1 from curl_mime_data.md
  2. .TH curl_mime_data 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_mime_data \- set a mime part\(aqs body data from memory
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_mime_data(curl_mimepart *part, const char *data,
  9. size_t datasize);
  10. .fi
  11. .SH DESCRIPTION
  12. \fIcurl_mime_data(3)\fP sets a mime part\(aqs body content from memory data.
  13. \fIpart\fP is the mime part to assign contents to, created with
  14. \fIcurl_mime_addpart(3)\fP.
  15. \fIdata\fP points to the data that gets copied by this function. The storage
  16. may safely be reused after the call.
  17. \fIdatasize\fP is the number of bytes \fIdata\fP points to. It can be set to
  18. \fICURL_ZERO_TERMINATED\fP to indicate \fIdata\fP is a null\-terminated
  19. character string.
  20. Setting a part\(aqs contents multiple times is valid: only the value set by the
  21. last call is retained. It is possible to unassign part\(aqs contents by setting
  22. \fIdata\fP to NULL.
  23. Setting large data is memory consuming: one might consider using
  24. \fIcurl_mime_data_cb(3)\fP in such a case.
  25. .SH PROTOCOLS
  26. This functionality affects http, imap and smtp
  27. .SH EXAMPLE
  28. .nf
  29. int main(void)
  30. {
  31. curl_mime *mime;
  32. curl_mimepart *part;
  33. CURL *curl = curl_easy_init();
  34. if(curl) {
  35. /* create a mime handle */
  36. mime = curl_mime_init(curl);
  37. /* add a part */
  38. part = curl_mime_addpart(mime);
  39. /* add data to the part */
  40. curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
  41. }
  42. }
  43. .fi
  44. .SH AVAILABILITY
  45. Added in curl 7.56.0
  46. .SH RETURN VALUE
  47. CURLE_OK or a CURL error code upon failure.
  48. .SH SEE ALSO
  49. .BR curl_mime_addpart (3),
  50. .BR curl_mime_data_cb (3),
  51. .BR curl_mime_name (3),
  52. .BR curl_mime_type (3)