Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / curl_mime_data.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2017, 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.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_data 3 "September 22, 2017" "libcurl 7.59.0" "libcurl Manual"
23
24 .SH NAME
25 curl_mime_data - set a mime part's body data from memory
26 .SH SYNOPSIS
27 .B #include <curl/curl.h>
28 .sp
29 .BI "CURLcode curl_mime_data(curl_mimepart * " part ", const char * " data
30 .BI ", size_t " datasize ");"
31 .ad
32 .SH DESCRIPTION
33 \fIcurl_mime_data(3)\fP sets a mime part's body content from memory data.
34
35 \fIdata\fP points to the data bytes: those are copied to the part and their
36 storage may safely be reused after call.
37 \fIdatasize\fP is the number of data bytes: it can be set to
38 \fICURL_ZERO_TERMINATED\fP to indicate \fIdata\fP is a nul-terminated
39 character string.
40 \fIpart\fP is the part's to assign contents to.
41
42 Setting a part's contents twice is valid: only the value set by the last call
43 is retained. It is possible to unassign part's contents by setting
44 \fIdata\fP to NULL.
45
46 Setting very large data is memory consuming: one might consider using
47 \fIcurl_mime_data_cb(3)\fP in such a case.
48 .SH AVAILABILITY
49 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
50 .SH RETURN VALUE
51 CURLE_OK or a CURL error code upon failure.
52 .SH EXAMPLE
53 .nf
54  curl_mime *mime;
55  curl_mimepart *part;
56
57  /* create a mime handle */
58  mime = curl_mime_init(easy);
59
60  /* add a part */
61  part = curl_mime_addpart(mime);
62
63  /* add data to the part  */
64  curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
65 .fi
66 .SH "SEE ALSO"
67 .BR curl_mime_addpart "(3),"
68 .BR curl_mime_data_cb "(3),"
69 .BR curl_mime_name "(3),"
70 .BR curl_mime_type "(3)"