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,
12                                   const char *filename);
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 null-terminated file's path name. The pointer
22       can be NULL to detach the previous  part  contents  settings.  Filename
23       storage 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

EXAMPLE

42        curl_mime *mime;
43        curl_mimepart *part;
44
45        /* create a mime handle */
46        mime = curl_mime_init(easy);
47
48        /* add a part */
49        part = curl_mime_addpart(mime);
50
51        /* send data from this file */
52        curl_mime_filedata(part, "image.png");
53
54        /* set name */
55        curl_mime_name(part, "data");
56

AVAILABILITY

58       As  long  as  at  least  one of HTTP, SMTP or IMAP is enabled. Added in
59       7.56.0.
60

RETURN VALUE

62       CURLE_OK or a CURL error code upon failure. CURLE_READ_ERROR is only an
63       indication  that the file is not yet readable: it can be safely ignored
64       at this time, but the file must be made readable before the  pertaining
65       easy handle is performed.
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.82.0                 November 26, 2021         curl_mime_filedata(3)
Impressum