1curl_mime_filedata(3)           libcurl Manual           curl_mime_filedata(3)
2
3
4

NAME

6       curl_mime_filedata - set a mime part's body data from a file contents
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode  curl_mime_filedata(curl_mimepart  * part,  const char * file‐
12       name);
13

DESCRIPTION

15       curl_mime_filedata(3) sets a mime part's body content  from  the  named
16       file's  contents.  This is an alternative to curl_mime_data(3) for set‐
17       ting data to a mime part.
18
19       part is the part's to assign contents to.
20
21       filename points to the nul-terminated file's path name. The pointer can
22       be  NULL to detach the previous part contents settings.  Filename stor‐
23       age can be safely be reused after this call.
24
25       As a side effect, the part's remote file name is set to the  base  name
26       of  the  given filename if it is a valid named file. This can be undone
27       or overridden by a subsequent call to curl_mime_filename(3).
28
29       The contents of the file is read during the file transfer in a  stream‐
30       ing  manner  to  allow huge files to get transferred without using much
31       memory. It therefore requires that the file is kept intact  during  the
32       entire request.
33
34       If  the file size cannot be determined before actually reading it (such
35       as for a device or named pipe), the whole mime structure containing the
36       part will be transferred as chunks by HTTP and rejected by IMAP.
37
38       Setting  a  part's  contents  twice is valid: only the value set by the
39       last call is retained.
40

AVAILABILITY

42       As long as at least one of HTTP, SMTP or  IMAP  is  enabled.  Added  in
43       7.56.0.
44

RETURN VALUE

46       CURLE_OK or a CURL error code upon failure. CURLE_READ_ERROR is only an
47       indication that the file is not yet readable: it can be safely  ignored
48       at  this time, but the file must be made readable before the pertaining
49       easy handle is performed.
50

EXAMPLE

52        curl_mime *mime;
53        curl_mimepart *part;
54
55        /* create a mime handle */
56        mime = curl_mime_init(easy);
57
58        /* add a part */
59        part = curl_mime_addpart(mime);
60
61        /* send data from this file */
62        curl_mime_filedata(part, "image.png");
63
64        /* set name */
65        curl_mime_name(part, "data");
66

SEE ALSO

68       curl_mime_addpart(3),     curl_mime_data(3),     curl_mime_filename(3),
69       curl_mime_name(3)
70
71
72
73libcurl 7.64.0                  April 17, 2018           curl_mime_filedata(3)
Impressum