• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_UPLOAD_BUFFERSIZE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_BUFFERSIZE (3)
9  - CURLOPT_READFUNCTION (3)
10  - CURLOPT_TCP_NODELAY (3)
11---
12
13# NAME
14
15CURLOPT_UPLOAD_BUFFERSIZE - upload buffer size
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD_BUFFERSIZE, long size);
23~~~
24
25# DESCRIPTION
26
27Pass a long specifying your preferred *size* (in bytes) for the upload
28buffer in libcurl. It makes libcurl uses a larger buffer that gets passed to
29the next layer in the stack to get sent off. In some setups and for some
30protocols, there is a huge performance benefit of having a larger upload
31buffer.
32
33This is just treated as a request, not an order. You cannot be guaranteed to
34actually get the given size.
35
36The upload buffer size is by default 64 kilobytes. The maximum buffer size
37allowed to be set is 2 megabytes. The minimum buffer size allowed to be set is
3816 kilobytes.
39
40The upload buffer is allocated on-demand - so if the handle is not used for
41upload, this buffer is not allocated at all.
42
43DO NOT set this option on a handle that is currently used for an active
44transfer as that may lead to unintended consequences.
45
46# DEFAULT
47
4865536 bytes
49
50# PROTOCOLS
51
52All
53
54# EXAMPLE
55
56~~~c
57int main(void)
58{
59  CURL *curl = curl_easy_init();
60  if(curl) {
61    CURLcode res;
62    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/foo.bin");
63
64    /* ask libcurl to allocate a larger upload buffer */
65    curl_easy_setopt(curl, CURLOPT_UPLOAD_BUFFERSIZE, 120000L);
66
67    res = curl_easy_perform(curl);
68
69    curl_easy_cleanup(curl);
70  }
71}
72~~~
73
74# AVAILABILITY
75
76Added in 7.62.0.
77
78# RETURN VALUE
79
80Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
81