CURLOPT_INFILESIZE_LARGE.md (1838B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_INFILESIZE_LARGE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_CONTENT_LENGTH_UPLOAD_T (3) 9 - CURLOPT_INFILESIZE (3) 10 - CURLOPT_UPLOAD (3) 11 Protocol: 12 - All 13 Added-in: 7.11.0 14 --- 15 16 # NAME 17 18 CURLOPT_INFILESIZE_LARGE - size of the input file to send off 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE_LARGE, 26 curl_off_t filesize); 27 ~~~ 28 29 # DESCRIPTION 30 31 When uploading a file to a remote site, *filesize* should be used to tell 32 libcurl what the expected size of the input file is. This value must be passed 33 as a **curl_off_t**. 34 35 For uploading using SCP, this option or CURLOPT_INFILESIZE(3) is 36 mandatory. 37 38 To unset this value again, set it to -1. 39 40 When sending emails using SMTP, this command can be used to specify the 41 optional SIZE parameter for the MAIL FROM command. 42 43 This option does not limit how much data libcurl actually sends, as that is 44 controlled entirely by what the read callback returns, but telling one value 45 and sending a different amount may lead to errors. 46 47 # DEFAULT 48 49 Unset 50 51 # %PROTOCOLS% 52 53 # EXAMPLE 54 55 ~~~c 56 #define FILE_SIZE 123456 57 58 int main(void) 59 { 60 CURL *curl = curl_easy_init(); 61 if(curl) { 62 curl_off_t uploadsize = FILE_SIZE; 63 64 curl_easy_setopt(curl, CURLOPT_URL, 65 "ftp://example.com/destination.tar.gz"); 66 67 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); 68 69 curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadsize); 70 71 curl_easy_perform(curl); 72 } 73 } 74 ~~~ 75 76 # HISTORY 77 78 SMTP support added in 7.23.0 79 80 # %AVAILABILITY% 81 82 # RETURN VALUE 83 84 curl_easy_setopt(3) 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).