curl_mime_type.3 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2020, 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.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_type 3 "22 August 2017" "libcurl 7.56.0" "libcurl Manual"
  23. .SH NAME
  24. curl_mime_type - set a mime part's content type
  25. .SH SYNOPSIS
  26. .B #include <curl/curl.h>
  27. .sp
  28. .BI "CURLcode curl_mime_type(curl_mimepart * " part ,
  29. .BI "const char * " mimetype ");"
  30. .ad
  31. .SH DESCRIPTION
  32. \fIcurl_mime_type(3)\fP sets a mime part's content type.
  33. \fIpart\fP is the part's handle to assign the content type to.
  34. \fImimetype\fP points to the null-terminated file mime type string; it may be
  35. set to NULL to remove a previously attached mime type.
  36. The mime type string is copied into the part, thus the associated storage may
  37. safely be released or reused after call. Setting a part's type twice is valid:
  38. only the value set by the last call is retained.
  39. In the absence of a mime type and if needed by the protocol specifications,
  40. a default mime type is determined by the context:
  41. .br
  42. - If set as a custom header, use this value.
  43. .br
  44. - application/form-data for an HTTP form post.
  45. .br
  46. - If a remote file name is set, the mime type is taken from the file name
  47. extension, or application/octet-stream by default.
  48. .br
  49. - For a multipart part, multipart/mixed.
  50. .br
  51. - text/plain in other cases.
  52. .SH AVAILABILITY
  53. As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0.
  54. .SH RETURN VALUE
  55. CURLE_OK or a CURL error code upon failure.
  56. .SH EXAMPLE
  57. .nf
  58. curl_mime *mime;
  59. curl_mimepart *part;
  60. /* create a mime handle */
  61. mime = curl_mime_init(easy);
  62. /* add a part */
  63. part = curl_mime_addpart(mime);
  64. /* get data from this file */
  65. curl_mime_filedata(part, "image.png");
  66. /* content-type for this part */
  67. curl_mime_type(part, "image/png");
  68. /* set name */
  69. curl_mime_name(part, "image");
  70. .fi
  71. .SH "SEE ALSO"
  72. .BR curl_mime_addpart "(3),"
  73. .BR curl_mime_name "(3),"
  74. .BR curl_mime_data "(3)"