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