Unverified Commit eae21db9 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

docs/curl_mime_*.3: added examples

parent 889723b0
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -38,6 +38,21 @@ appended.
As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
.SH RETURN VALUE
A mime part structure handle, or NULL upon failure.
.SH EXAMPLE
.nf
 struct curl_mime *mime;
 struct mimepart *part;

 /* create a mime handle */
 mime = curl_mime_init(easy);

 /* add a part */
 part = curl_mime_addpart(mime);

 /* continue and set name + data to the part */
 curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
 curl_mime_name(part, "data", CURL_ZERO_TERMINATED);
.fi
.SH "SEE ALSO"
.BR curl_mime_init "(3),"
.BR curl_mime_name "(3),"
+14 −0
Original line number Diff line number Diff line
@@ -48,6 +48,20 @@ Setting very large data is memory consuming: one might consider using
As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
.SH RETURN VALUE
CURLE_OK or a CURL error code upon failure.
.SH EXAMPLE
.nf
 struct curl_mime *mime;
 struct mimepart *part;

 /* create a mime handle */
 mime = curl_mime_init(easy);

 /* add a part */
 part = curl_mime_addpart(mime);

 /* add data to the part  */
 curl_mime_data(part, "raw contents to send", CURL_ZERO_TERMINATED);
.fi
.SH "SEE ALSO"
.BR curl_mime_addpart "(3),"
.BR curl_mime_data_cb "(3)"
+2 −0
Original line number Diff line number Diff line
@@ -156,3 +156,5 @@ int seek_callback(void *arg, curl_off_t offset, int origin)

.SH "SEE ALSO"
.BR curl_mime_addpart "(3)"
.BR curl_mime_data "(3)"
.BR curl_mime_name "(3)"
+24 −2
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@ curl_mime_filedata - set a mime part's body data from a file contents
.ad
.SH DESCRIPTION
\fIcurl_mime_filedata(3)\fP sets a mime part's body content from the named
file's contents.
file's contents. This is an alernative to \fIcurl_mime_data(3)\fP for setting
data to a mime part.

\fIpart\fP is the part's to assign contents to.

@@ -42,14 +43,35 @@ As a side effect, the part's remote file name is set to the base name of the
given \fIfilename\fP if it is a valid named file. This can be undone or
overriden by a subsequent call to \fIcurl_mime_filename(3)\fP.

The contents of the file is read during the file transfer in a streaming
manner to allow huge files to get transfered without using much memory. It
therefore requires that the file is kept intact during the entire request.

Setting a part's contents twice is valid: only the value set by the last call
is retained.

.SH AVAILABILITY
As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
.SH RETURN VALUE
CURLE_OK or a CURL error code upon failure.
.SH EXAMPLE
.nf
 struct curl_mime *mime;
 struct mimepart *part;

 /* create a mime handle */
 mime = curl_mime_init(easy);

 /* add a part */
 part = curl_mime_addpart(mime);

 /* send data from this file */
 curl_mime_filedata(part, "image.png");

 /* set name */
 curl_mime_name(part, "data", CURL_ZERO_TERMINATED);
.fi
.SH "SEE ALSO"
.BR curl_mime_addpart "(3),"
.BR curl_mime_data "(3),"
.BR curl_mime_filename "(3)"
.BR curl_mime_name "(3),"
+22 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ content source. A part's remote file name is transmitted to the server in the
associated Content-Disposition generated header.

\fIpart\fP is the part's handle to assign the remote file name to.

\fIfilename\fP points to the nul-terminated file name string; it may be set to
NULL to remove a previously attached remote file name.

@@ -45,6 +46,27 @@ name twice is valid: only the value set by the last call is retained.
As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
.SH RETURN VALUE
CURLE_OK or a CURL error code upon failure.
.SH EXAMPLE
.nf
 struct curl_mime *mime;
 struct mimepart *part;

 /* create a mime handle */
 mime = curl_mime_init(easy);

 /* add a part */
 part = curl_mime_addpart(mime);

 /* send image data from memory */
 curl_mime_data(part, imagebuf, imagebuf_len);

 /* set a file name to make it look like a file upload */
 curl_mime_filename(part, "image.png");

 /* set name */
 curl_mime_name(part, "data", CURL_ZERO_TERMINATED);
.fi
.SH "SEE ALSO"
.BR curl_mime_addpart "(3) "
.BR curl_mime_filedata "(3) "
.BR curl_mime_data "(3) "
Loading