1CURLOPT_MAXFILESIZE(3) libcurl 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 size);
12
14 Pass a long as parameter. This allows you to specify the maximum size
15 (in bytes) of a file to download. If the file requested is found larger
16 than this value, the transfer will not start and CURLE_FILESIZE_EX‐
17 CEEDED will be returned.
18
19 The file size is not always known prior to download, and for such files
20 this option has no effect even if the file transfer ends up being
21 larger than this given limit.
22
23 If you want a limit above 2GB, use CURLOPT_MAXFILESIZE_LARGE(3).
24
26 None
27
29 FTP, HTTP and MQTT
30
32 CURL *curl = curl_easy_init();
33 if(curl) {
34 CURLcode ret;
35 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
36 /* refuse to download if larger than 1000 bytes! */
37 curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L);
38 ret = curl_easy_perform(curl);
39 }
40
42 Always
43
45 Returns CURLE_OK
46
48 CURLOPT_MAXFILESIZE_LARGE(3), CURLOPT_MAX_RECV_SPEED_LARGE(3),
49
50
51
52ibcurl 8.2.1 April 26, 2023 CURLOPT_MAXFILESIZE(3)