1CURLOPT_MAXFILESIZE(3) curl_easy_setopt options CURLOPT_MAXFILESIZE(3)
2
3
4
6 CURLOPT_MAXFILESIZE - maximum file size allowed to download
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE, long
12 size);
13
15 Pass a long as parameter. This allows you to specify the maximum size
16 (in bytes) of a file to download. If the file requested is found larger
17 than this value, the transfer will not start and CURLE_FILE‐
18 SIZE_EXCEEDED will be returned.
19
20 The file size is not always known prior to download, and for such files
21 this option has no effect even if the file transfer ends up being
22 larger than this given limit. This concerns both FTP and HTTP trans‐
23 fers.
24
25 If you want a limit above 2GB, use CURLOPT_MAXFILESIZE_LARGE(3).
26
28 None
29
31 FTP and HTTP
32
34 CURL *curl = curl_easy_init();
35 if(curl) {
36 CURLcode ret;
37 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
38 /* refuse to download if larger than 1000 bytes! */
39 curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L);
40 ret = curl_easy_perform(curl);
41 }
42
44 Always
45
47 Returns CURLE_OK
48
50 CURLOPT_MAXFILESIZE_LARGE(3), CURLOPT_MAX_RECV_SPEED_LARGE(3),
51
52
53
54libcurl 7.61.1 May 30, 2017 CURLOPT_MAXFILESIZE(3)