1 .\" **************************************************************************
3 .\" * Project ___| | | | _ \| |
4 .\" * / __| | | | |_) | |
5 .\" * | (__| |_| | _ <| |___
6 .\" * \___|\___/|_| \_\_____|
8 .\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
21 .\" **************************************************************************
22 .TH curl_mime_filedata 3 "January 14, 2018" "libcurl 7.59.0" "libcurl Manual"
25 curl_mime_filedata - set a mime part's body data from a file contents
27 .B #include <curl/curl.h>
29 .BI "CURLcode curl_mime_filedata(curl_mimepart * " part ,
30 .BI " const char * " filename ");"
33 \fIcurl_mime_filedata(3)\fP sets a mime part's body content from the named
34 file's contents. This is an alernative to \fIcurl_mime_data(3)\fP for setting
37 \fIpart\fP is the part's to assign contents to.
39 \fIfilename\fP points to the nul-terminated file's path name. The pointer can
40 be NULL to detach the previous part contents settings. Filename storage can be
41 safely be reused after this call.
43 As a side effect, the part's remote file name is set to the base name of the
44 given \fIfilename\fP if it is a valid named file. This can be undone or
45 overridden by a subsequent call to \fIcurl_mime_filename(3)\fP.
47 The contents of the file is read during the file transfer in a streaming
48 manner to allow huge files to get transferred without using much memory. It
49 therefore requires that the file is kept intact during the entire request.
51 If the file size cannot be determined before actually reading it (such as for
52 a device or named pipe), the whole mime structure containing the part
53 will be transferred as chunks by HTTP and rejected by IMAP.
55 Setting a part's contents twice is valid: only the value set by the last call
58 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
60 CURLE_OK or a CURL error code upon failure. CURLE_READ_ERROR is only an
61 indication that the file is not yet readable: it can be safely ignored at
62 this time, but the file must be made readable before the pertaining
63 easy handle is performed.
69 /* create a mime handle */
70 mime = curl_mime_init(easy);
73 part = curl_mime_addpart(mime);
75 /* send data from this file */
76 curl_mime_filedata(part, "image.png");
79 curl_mime_name(part, "data");
82 .BR curl_mime_addpart "(3),"
83 .BR curl_mime_data "(3),"
84 .BR curl_mime_filename "(3),"
85 .BR curl_mime_name "(3)"