CURLOPT_UPLOAD_BUFFERSIZE(3)

CURLOPT_UPLOAD_BUFFERSIZE(3) πŸ’…βœ¨

okay so bestie, welcome to the Library Functions Manual β€” this is the whole vibe on CURLOPT_UPLOAD_BUFFERSIZE(3), and yes it is exactly as iconic as it sounds 🫢

πŸ’– NAME πŸ’–

CURLOPT_UPLOAD_BUFFERSIZE β€” upload buffer size

✨ SYNOPSIS ✨

       #include <curl/curl.h>

       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD_BUFFERSIZE, long size);

πŸ¦‹ DESCRIPTION πŸ¦‹

Pass a long specifying your preferred size (in bytes) for the upload buffer in libcurl. It makes libcurl use a larger buffer that gets passed to the next layer in the stack to get sent off. In some setups and for some protocols, there is a huge performance benefit of having a larger upload buffer. like, actually huge, not just delulu hype ✨

This is just treated as a request, not an order. You cannot be guaranteed to actually get the given size. so don't come for libcurl if it doesn't match exactly, bestie 😭

The upload buffer size is by default 64 kilobytes. The maximum buffer size allowed to be set is 2 megabytes. The minimum buffer size allowed to be set is 16 kilobytes.

The upload buffer is allocated on-demand β€” so if the handle is not used for upload, this buffer is not allocated at all. slay, no wasted allocation energy πŸ’…

🚨 DO NOT set this option on a handle that is currently used for an active transfer as that may lead to unintended consequences. fr fr, do not do it, this is not a drill πŸ’€

πŸŽ€ DEFAULT πŸŽ€

65536 bytes β€” that's the 64 kilobytes from above, bestie, we stay consistent πŸ‘‘

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols β€” all of them, every single one 🫢

πŸ”₯ EXAMPLE πŸ”₯

okay here's the little C moment, copied exactly because we do not mess with code in this group chat πŸ’…

       int main(void)
       {
         CURL *curl = curl_easy_init();
         if(curl) {
           CURLcode result;
           curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");

           /* ask libcurl to allocate a larger upload buffer */
           curl_easy_setopt(curl, CURLOPT_UPLOAD_BUFFERSIZE, 120000L);

           result = curl_easy_perform(curl);

           curl_easy_cleanup(curl);
         }
       }

⭐ AVAILABILITY ⭐

Added in curl 7.62.0 β€” vintage but still serving ✨

πŸ’œ RETURN VALUE πŸ’œ

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

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). so if it's not 0, go read that page, iykyk 🧚

πŸ‘‘ SEE ALSO πŸ‘‘

go give these a read too, bestie β€” the lore is connected 🌈


xoxo, this page is from libcurl, dated 2026-10-12 β€” now go set your buffer size with main character energy πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from