| 1 |
.\" ************************************************************************** |
| 2 |
.\" * _ _ ____ _ |
| 3 |
.\" * Project ___| | | | _ \| | |
| 4 |
.\" * / __| | | | |_) | | |
| 5 |
.\" * | (__| |_| | _ <| |___ |
| 6 |
.\" * \___|\___/|_| \_\_____| |
| 7 |
.\" * |
| 8 |
.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <[email protected]>, 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_filedata 3 "22 August 2017" "libcurl 7.56.0" "libcurl Manual" |
| 23 |
.SH NAME |
| 24 |
curl_mime_filedata - set a mime part's body data from a file contents |
| 25 |
.SH SYNOPSIS |
| 26 |
.B #include <curl/curl.h> |
| 27 |
.sp |
| 28 |
.BI "CURLcode curl_mime_filedata(curl_mimepart * " part , |
| 29 |
.BI " const char * " filename ");" |
| 30 |
.ad |
| 31 |
.SH DESCRIPTION |
| 32 |
\fIcurl_mime_filedata(3)\fP sets a mime part's body content from the named |
| 33 |
file's contents. This is an alternative to \fIcurl_mime_data(3)\fP for setting |
| 34 |
data to a mime part. |
| 35 |
|
| 36 |
\fIpart\fP is the part's to assign contents to. |
| 37 |
|
| 38 |
\fIfilename\fP points to the nul-terminated file's path name. The pointer can |
| 39 |
be NULL to detach the previous part contents settings. Filename storage can be |
| 40 |
safely be reused after this call. |
| 41 |
|
| 42 |
As a side effect, the part's remote file name is set to the base name of the |
| 43 |
given \fIfilename\fP if it is a valid named file. This can be undone or |
| 44 |
overridden by a subsequent call to \fIcurl_mime_filename(3)\fP. |
| 45 |
|
| 46 |
The contents of the file is read during the file transfer in a streaming |
| 47 |
manner to allow huge files to get transferred without using much memory. It |
| 48 |
therefore requires that the file is kept intact during the entire request. |
| 49 |
|
| 50 |
If the file size cannot be determined before actually reading it (such as for |
| 51 |
a device or named pipe), the whole mime structure containing the part |
| 52 |
will be transferred as chunks by HTTP and rejected by IMAP. |
| 53 |
|
| 54 |
Setting a part's contents twice is valid: only the value set by the last call |
| 55 |
is retained. |
| 56 |
.SH AVAILABILITY |
| 57 |
As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. |
| 58 |
.SH RETURN VALUE |
| 59 |
CURLE_OK or a CURL error code upon failure. CURLE_READ_ERROR is only an |
| 60 |
indication that the file is not yet readable: it can be safely ignored at |
| 61 |
this time, but the file must be made readable before the pertaining |
| 62 |
easy handle is performed. |
| 63 |
.SH EXAMPLE |
| 64 |
.nf |
| 65 |
curl_mime *mime; |
| 66 |
curl_mimepart *part; |
| 67 |
|
| 68 |
/* create a mime handle */ |
| 69 |
mime = curl_mime_init(easy); |
| 70 |
|
| 71 |
/* add a part */ |
| 72 |
part = curl_mime_addpart(mime); |
| 73 |
|
| 74 |
/* send data from this file */ |
| 75 |
curl_mime_filedata(part, "image.png"); |
| 76 |
|
| 77 |
/* set name */ |
| 78 |
curl_mime_name(part, "data"); |
| 79 |
.fi |
| 80 |
.SH "SEE ALSO" |
| 81 |
.BR curl_mime_addpart "(3)," |
| 82 |
.BR curl_mime_data "(3)," |
| 83 |
.BR curl_mime_filename "(3)," |
| 84 |
.BR curl_mime_name "(3)" |