curl_mime_type.3 2.8 KB

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