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