1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_mime_data 5Section: 3 6Source: libcurl 7See-also: 8 - curl_mime_addpart (3) 9 - curl_mime_data_cb (3) 10 - curl_mime_name (3) 11 - curl_mime_type (3) 12--- 13 14# NAME 15 16curl_mime_data - set a mime part's body data from memory 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLcode curl_mime_data(curl_mimepart *part, const char *data, 24 size_t datasize); 25~~~ 26 27# DESCRIPTION 28 29curl_mime_data(3) sets a mime part's body content from memory data. 30 31*part* is the mime part to assign contents to, created with 32curl_mime_addpart(3). 33 34*data* points to the data that gets copied by this function. The storage 35may safely be reused after the call. 36 37*datasize* is the number of bytes *data* points to. It can be set to 38*CURL_ZERO_TERMINATED* to indicate *data* is a null-terminated 39character string. 40 41Setting a part's contents multiple times is valid: only the value set by the 42last call is retained. It is possible to unassign part's contents by setting 43*data* to NULL. 44 45Setting large data is memory consuming: one might consider using 46curl_mime_data_cb(3) in such a case. 47 48# EXAMPLE 49 50~~~c 51int main(void) 52{ 53 curl_mime *mime; 54 curl_mimepart *part; 55 56 CURL *curl = curl_easy_init(); 57 if(curl) { 58 /* create a mime handle */ 59 mime = curl_mime_init(curl); 60 61 /* add a part */ 62 part = curl_mime_addpart(mime); 63 64 /* add data to the part */ 65 curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED); 66 } 67} 68~~~ 69 70# AVAILABILITY 71 72As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. 73 74# RETURN VALUE 75 76CURLE_OK or a CURL error code upon failure. 77