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