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