Annotation of embedaddon/curl/docs/libcurl/opts/CURLOPT_UPLOAD.3, revision 1.1

1.1     ! misho       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.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: .\"
        !            23: .TH CURLOPT_UPLOAD 3 "March 23, 2020" "libcurl 7.70.0" "curl_easy_setopt options"
        !            24: 
        !            25: .SH NAME
        !            26: CURLOPT_UPLOAD \- enable data upload
        !            27: .SH SYNOPSIS
        !            28: #include <curl/curl.h>
        !            29: 
        !            30: CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD, long upload);
        !            31: .SH DESCRIPTION
        !            32: The long parameter \fIupload\fP set to 1 tells the library to prepare for and
        !            33: perform an upload. The \fICURLOPT_READDATA(3)\fP and
        !            34: \fICURLOPT_INFILESIZE(3)\fP or \fICURLOPT_INFILESIZE_LARGE(3)\fP options are
        !            35: also interesting for uploads. If the protocol is HTTP, uploading means using
        !            36: the PUT request unless you tell libcurl otherwise.
        !            37: 
        !            38: Using PUT with HTTP 1.1 implies the use of a "Expect: 100-continue" header.
        !            39: You can disable this header with \fICURLOPT_HTTPHEADER(3)\fP as usual.
        !            40: 
        !            41: If you use PUT to an HTTP 1.1 server, you can upload data without knowing the
        !            42: size before starting the transfer if you use chunked encoding. You enable this
        !            43: by adding a header like "Transfer-Encoding: chunked" with
        !            44: \fICURLOPT_HTTPHEADER(3)\fP. With HTTP 1.0 or without chunked transfer, you
        !            45: must specify the size.
        !            46: .SH DEFAULT
        !            47: 0, default is download
        !            48: .SH PROTOCOLS
        !            49: Most
        !            50: .SH EXAMPLE
        !            51: .nf
        !            52: CURL *curl = curl_easy_init();
        !            53: if(curl) {
        !            54:   /* we want to use our own read function */
        !            55:   curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
        !            56: 
        !            57:   /* enable uploading */
        !            58:   curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
        !            59: 
        !            60:   /* specify target */
        !            61:   curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
        !            62: 
        !            63:   /* now specify which pointer to pass to our callback */
        !            64:   curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
        !            65: 
        !            66:   /* Set the size of the file to upload */
        !            67:   curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize);
        !            68: 
        !            69:   /* Now run off and do what you've been told! */
        !            70:   curl_easy_perform(curl);
        !            71: }
        !            72: .fi
        !            73: .SH AVAILABILITY
        !            74: Always
        !            75: .SH RETURN VALUE
        !            76: Returns CURLE_OK
        !            77: .SH "SEE ALSO"
        !            78: .BR CURLOPT_PUT "(3), " CURLOPT_READFUNCTION "(3), "
        !            79: .BR CURLOPT_INFILESIZE_LARGE "(3), "

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>