GNURLOPT_INFILESIZE_LARGE(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_INFILESIZE_LARGE(3) β€” like, the large version, bestie

okay so first things first: this is one of those curl_easy_setopt options from the gnurl manual (yes, gnurl, she's got her own thing going on πŸ’–), and today we're talking about telling libcurl how big your upload is gonna be. no cap, it's simpler than it sounds.


✨ NAME ✨

CURLOPT_INFILESIZE_LARGE β€” literally just "set the size of the input file to send off." that's it. that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE_LARGE,
                          curl_off_t filesize);

look at her. iconic signature. the curl_off_t is right there in the declaration so you already know the type matters, bestie πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so when you're uploading a file to a remote site, filesize is what you use to tell libcurl what the expected size of the input file is. and the way that this value must be passed as a curl_off_t β€” yeah, that's not a suggestion, that's a rule. don't come at her with an int, she will not be having it 😭

for uploading using SCP, this option or CURLOPT_INFILESIZE(3) is mandatory. mandatory mandatory. no skipping, no "I'll do it later," it's giving required homework πŸ“š

wanna unset this value again? set it to -1. boom, gone, cleansed, cleared 🫧

and when you're sending emails using SMTP, this command can be used to specify the optional SIZE parameter for the MAIL FROM command. cute little bonus feature, slay ✨

⚠️ big important warning energy: this option does not limit how much data libcurl will actually send. that is controlled entirely by what the read callback returns. so if you tell her one value and then send a different amount? that may lead to errors. like, the audacity. keep them matching, bestie πŸ’€

πŸ“ DEFAULT πŸ“

Unset β€” she starts out with nothing, mysterious, unbothered, minding her business πŸ™ˆ


🌈 PROTOCOLS 🌈

Many β€” she's versatile, she's everywhere, she's the main character of protocols πŸ’…


🧚 EXAMPLE 🧚

CURL *curl = curl_easy_init();
if(curl) {
  curl_off_t uploadsize = FILE_SIZE;

  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/destination.tar.gz");

  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);

  curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadsize);

  curl_easy_perform(curl);
}

see how it all comes together?? curl_easy_init, set the URL, set CURLOPT_UPLOAD to 1L, hand over that uploadsize as a curl_off_t, and let curl_easy_perform do her thing. ate and left no crumbs πŸ”₯


⭐ AVAILABILITY ⭐

SMTP support was added in 7.23.0. so if you're on something older than that, SMTP's not gonna know what you're talking about, and that's just how it is 🫢


πŸ’œ RETURN VALUE πŸ’œ

returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. like a vibe check for whether your libcurl even knows her 😌


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, bestie, you're officially caught up πŸ’– this cute little drop came from libcurl 7.37.0, dated 17 Jun 2014 β€” vintage, but still serving βœ¨πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from