CURLOPT_INFILESIZE_LARGE(3)

πŸ’… CURLOPT_INFILESIZE_LARGE(3) β€” like, the libcurl manual, bestie edition πŸŽ€

okay so real talk: this is a page from the Library Functions Manual, and today we're learning CURLOPT_INFILESIZE_LARGE β€” the glow-up sibling of the regular infilesize option, but for when your file is big big. Let's get into it ✨


🌸 NAME 🌸

CURLOPT_INFILESIZE_LARGE β€” telling libcurl how big your input file is before you send it off. like a vibe check for your upload, but with bytes πŸ“


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

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

that's it, that's the whole mood πŸ’…


πŸ’– DESCRIPTION πŸ’–

so when you're uploading a file to some remote site, you use filesize to tell libcurl what the expected size of the input file is. and bestie, this value has to be passed as a curl_off_t β€” no shortcuts, no "close enough" types, it's giving specific πŸ’€

btw if you're uploading using SCP, this option or CURLOPT_INFILESIZE(3) is mandatory β€” like, not optional, not "maybe later", mandatory mandatory. main character requirement fr fr πŸ‘‘

want to unset this value again? just set it to -1. that's the undo button, no cap πŸ™ˆ

and oh! 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 πŸŽ€

ok here's the important caveat, listen up πŸ”₯: this option does not limit how much data libcurl actually sends. that's controlled entirely by what the read callback returns β€” periodt. so if you tell it one value and then send a different amount, you may get errors. telling lies to libcurl = consequences, iykyk 😭

⭐ DEFAULT ⭐

Unset β€” literally no value, it's a blank canvas, an empty group chat πŸ’€


🌈 PROTOCOLS 🌈

This functionality affects all supported protocols. every single one. universal slay 🫢


πŸ“ EXAMPLE πŸ“

ok here's a whole little program, isn't she precious:

#define FILE_SIZE 123456

int main(void)
{
  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 she sets the URL, turns on CURLOPT_UPLOAD with 1L, then drops in the big file size? that's the whole flow, ate and left no crumbs πŸ”₯


🧚 HISTORY 🧚

SMTP support was added in 7.23.0 β€” a lil throwback moment for the email girlies πŸ’Œ


πŸ‘‘ AVAILABILITY πŸ‘‘

Added in curl 7.11.0. she's been iconic for a minute ⭐


πŸ’œ RETURN VALUE πŸ’œ

curl_easy_setopt(3) returns a CURLcode indicating success or error.

  • CURLE_OK (0) means everything was OK β€” like, we're so back πŸ’–
  • non-zero means an error occurred β€” check libcurl-errors(3) for the full tea 😭

πŸŽ€ SEE ALSO πŸŽ€

go read those too, they're all connected bestie, it's a whole ecosystem πŸ¦‹


okay that's the page!! this was libcurl, dated 2026-10-12, and the page is CURLOPT_INFILESIZE_LARGE(3) β€” go forth and upload responsibly, mwah πŸ’‹βœ¨πŸŒΈ

πŸ“¦ where this page comes from