CURLOPT_INFILESIZE(3)
β¨ CURLOPT_INFILESIZE(3) β¨
okay so real talk, this one lives in the Library Functions Manual and it's genuinely one of the most useful little knobs in the whole libcurl lineup. bestie, let me put you on π
π NAME π
CURLOPT_INFILESIZE β literally just "how big is the file I'm sending off" π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE, long filesize);
πΈ DESCRIPTION πΈ
So when you're uploading a file to a remote site, filesize is the thing you pass to tell libcurl what the expected size of the input file is. That value must be passed as a long β no vibes-only guessing, actual type, okay? π
And if you're out here with files bigger than 2GB, go look at CURLOPT_INFILESIZE_LARGE(3) instead, that's the big-girl option π
Ngl, for uploading using SCP, this option or CURLOPT_INFILESIZE_LARGE(3) is mandatory. Not optional. Not a suggestion. Mandatory. π«Ά
Wanna unset this value again later? Set it to -1. That's it, that's the whole trick β¨
And here's a fun one: if you're using CURLOPT_UPLOAD(3) to an HTTP/1.1 server and this value is set to -1, libcurl does a chunked transfer-encoded upload. it's giving "no size, no problem" π₯
When sending emails using SMTP, this command can be used to specify the optional SIZE parameter for the MAIL FROM command. cute, right? π
β οΈ Okay important, listen up: this option does not limit how much data libcurl actually sends. That is controlled entirely by what the read callback returns. But telling one value and then sending a different amount may lead to errors. so likeβ¦ don't lie to libcurl, she remembers π
π DEFAULT π
Unset β¨ (living that unbothered no-value life)
π PROTOCOLS π
This functionality affects all supported protocols. all of them. every single one. slay π
π§ EXAMPLE π§
#define FILE_SIZE 12345L
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
long 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, uploadsize);
curl_easy_perform(curl);
}
}
look at her go ππ fully iconic, no notes.
π°οΈ HISTORY π°οΈ
- SMTP support added in 7.23.0 π¬
β AVAILABILITY β
Added in curl 7.1. vintage. a classic. the main character of early curl π«Ά
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error π
CURLE_OK(which is0) means everything was OK β we love a zero π- non-zero means an error occurred β go check
libcurl-errors(3)for the tea π
π SEE ALSO π
and that's the page, bestie! π¦ this lil gem comes to you courtesy of libcurl, dated 2026-10-12, and the page itself is CURLOPT_INFILESIZE(3) β go forth and tell libcurl your file size, she'll appreciate the honesty πβ¨π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms