2
0

curl_mime_filedata.3 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, 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. \fIpart\fP is the part's to assign contents to.
  36. \fIfilename\fP points to the nul-terminated file's path name. The pointer can
  37. be NULL to detach the previous part contents settings. Filename storage can be
  38. safely be reused after this call.
  39. As a side effect, the part's remote file name is set to the base name of the
  40. given \fIfilename\fP if it is a valid named file. This can be undone or
  41. overridden by a subsequent call to \fIcurl_mime_filename(3)\fP.
  42. The contents of the file is read during the file transfer in a streaming
  43. manner to allow huge files to get transferred without using much memory. It
  44. therefore requires that the file is kept intact during the entire request.
  45. If the file size cannot be determined before actually reading it (such as for
  46. a device or named pipe), the whole mime structure containing the part
  47. will be transferred as chunks by HTTP and rejected by IMAP.
  48. Setting a part's contents twice is valid: only the value set by the last call
  49. is retained.
  50. .SH AVAILABILITY
  51. As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
  52. .SH RETURN VALUE
  53. CURLE_OK or a CURL error code upon failure. CURLE_READ_ERROR is only an
  54. indication that the file is not yet readable: it can be safely ignored at
  55. this time, but the file must be made readable before the pertaining
  56. easy handle is performed.
  57. .SH EXAMPLE
  58. .nf
  59. curl_mime *mime;
  60. curl_mimepart *part;
  61. /* create a mime handle */
  62. mime = curl_mime_init(easy);
  63. /* add a part */
  64. part = curl_mime_addpart(mime);
  65. /* send data from this file */
  66. curl_mime_filedata(part, "image.png");
  67. /* set name */
  68. curl_mime_name(part, "data");
  69. .fi
  70. .SH "SEE ALSO"
  71. .BR curl_mime_addpart "(3),"
  72. .BR curl_mime_data "(3),"
  73. .BR curl_mime_filename "(3),"
  74. .BR curl_mime_name "(3)"