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_FILESIZE_EX‐
18 CEEDED 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.
23
24 If you want a limit above 2GB, use CURLOPT_MAXFILESIZE_LARGE(3).
25
27 None
28
30 FTP, HTTP and MQTT
31
33 CURL *curl = curl_easy_init();
34 if(curl) {
35 CURLcode ret;
36 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
37 /* refuse to download if larger than 1000 bytes! */
38 curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L);
39 ret = curl_easy_perform(curl);
40 }
41
43 Always
44
46 Returns CURLE_OK
47
49 CURLOPT_MAXFILESIZE_LARGE(3), CURLOPT_MAX_RECV_SPEED_LARGE(3),
50
51
52
53libcurl 7.79.1 July 23, 2021 CURLOPT_MAXFILESIZE(3)