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