quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl_mime_filename.md (2105B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: curl_mime_filename
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - curl_mime_addpart (3)
      9   - curl_mime_data (3)
     10   - curl_mime_filedata (3)
     11 Protocol:
     12   - HTTP
     13   - IMAP
     14   - SMTP
     15 Added-in: 7.56.0
     16 ---
     17 
     18 # NAME
     19 
     20 curl_mime_filename - set a mime part's remote filename
     21 
     22 # SYNOPSIS
     23 
     24 ~~~c
     25 #include <curl/curl.h>
     26 
     27 CURLcode curl_mime_filename(curl_mimepart *part,
     28                             const char *filename);
     29 ~~~
     30 
     31 # DESCRIPTION
     32 
     33 curl_mime_filename(3) sets a mime part's remote filename. When remote
     34 filename is set, content data is processed as a file, whatever is the part's
     35 content source. A part's remote filename is transmitted to the server in the
     36 associated Content-Disposition generated header.
     37 
     38 *part* is the part's handle to assign the remote filename to.
     39 
     40 *filename* points to the null-terminated filename string; it may be set
     41 to NULL to remove a previously attached remote filename.
     42 
     43 The remote filename string is copied into the part, thus the associated
     44 storage may safely be released or reused after call. Setting a part's file
     45 name multiple times is valid: only the value set by the last call is retained.
     46 
     47 # %PROTOCOLS%
     48 
     49 # EXAMPLE
     50 
     51 ~~~c
     52 
     53 static char imagebuf[]="imagedata";
     54 
     55 int main(void)
     56 {
     57   curl_mime *mime;
     58   curl_mimepart *part;
     59 
     60   CURL *curl = curl_easy_init();
     61   if(curl) {
     62     /* create a mime handle */
     63     mime = curl_mime_init(curl);
     64 
     65     /* add a part */
     66     part = curl_mime_addpart(mime);
     67 
     68     /* send image data from memory */
     69     curl_mime_data(part, imagebuf, sizeof(imagebuf));
     70 
     71     /* set a file name to make it look like a file upload */
     72     curl_mime_filename(part, "image.png");
     73 
     74     /* set name */
     75     curl_mime_name(part, "data");
     76   }
     77 }
     78 ~~~
     79 
     80 # %AVAILABILITY%
     81 
     82 # RETURN VALUE
     83 
     84 This function returns a CURLcode indicating success or error.
     85 
     86 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     87 libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3)
     88 there can be an error message stored in the error buffer when non-zero is
     89 returned.