1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_MAXFILESIZE_LARGE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_MAXFILESIZE (3)
9  - CURLOPT_MAX_RECV_SPEED_LARGE (3)
10Protocol:
11  - FTP
12  - HTTP
13  - MQTT
14---
15
16# NAME
17
18CURLOPT_MAXFILESIZE_LARGE - maximum file size allowed to download
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE_LARGE,
26                          curl_off_t size);
27~~~
28
29# DESCRIPTION
30
31Pass a curl_off_t as parameter. This specifies the maximum accepted *size*
32(in bytes) of a file to download. If the file requested is found larger than
33this value, the transfer is aborted and *CURLE_FILESIZE_EXCEEDED* is
34returned. Passing a zero *size* disables this, and passing a negative *size*
35yields a *CURLE_BAD_FUNCTION_ARGUMENT*.
36
37The file size is not always known prior to the download start, and for such
38transfers this option has no effect - even if the file transfer eventually
39ends up being larger than this given limit.
40
41Since 8.4.0, this option also stops ongoing transfers if they reach this
42threshold.
43
44# DEFAULT
45
460, meaning disabled.
47
48# EXAMPLE
49
50~~~c
51int main(void)
52{
53  CURL *curl = curl_easy_init();
54  if(curl) {
55    CURLcode ret;
56    curl_off_t ridiculous = (curl_off_t)1 << 48;
57    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
58    /* refuse to download if larger than ridiculous */
59    curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, ridiculous);
60    ret = curl_easy_perform(curl);
61  }
62}
63~~~
64
65# AVAILABILITY
66
67Added in 7.11.0
68
69# RETURN VALUE
70
71Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
72CURLE_BAD_FUNCTION_ARGUMENT if the size passed is invalid.
73