1CURLOPT_MAXFILESIZE(3)     curl_easy_setopt options     CURLOPT_MAXFILESIZE(3)
2
3
4

NAME

6       CURLOPT_MAXFILESIZE - maximum file size allowed to download
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE, long size);
12

DESCRIPTION

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

DEFAULT

26       None
27

PROTOCOLS

29       FTP, HTTP and MQTT
30

EXAMPLE

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

AVAILABILITY

42       Always
43

RETURN VALUE

45       Returns CURLE_OK
46

SEE ALSO

48       CURLOPT_MAXFILESIZE_LARGE(3), CURLOPT_MAX_RECV_SPEED_LARGE(3),
49
50
51
52libcurl 7.82.0                 November 26, 2021        CURLOPT_MAXFILESIZE(3)
Impressum