CURLOPT_MAXFILESIZE.3 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .\" generated by cd2nroff 0.1 from CURLOPT_MAXFILESIZE.md
  2. .TH CURLOPT_MAXFILESIZE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_MAXFILESIZE \- maximum file size allowed to download
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAXFILESIZE, long size);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long as parameter. This specifies the maximum accepted \fIsize\fP (in
  12. bytes) of a file to download. If the file requested is found larger than this
  13. value, the transfer is aborted and \fICURLE_FILESIZE_EXCEEDED\fP is returned.
  14. Passing a zero \fIsize\fP disables this, and passing a negative \fIsize\fP yields a
  15. \fICURLE_BAD_FUNCTION_ARGUMENT\fP.
  16. The file size is not always known prior to the download start, and for such
  17. transfers this option has no effect \- even if the file transfer eventually
  18. ends up being larger than this given limit.
  19. If you want a limit above 2GB, use \fICURLOPT_MAXFILESIZE_LARGE(3)\fP.
  20. Since 8.4.0, this option also stops ongoing transfers if they reach this
  21. threshold.
  22. .SH DEFAULT
  23. 0, meaning disabled.
  24. .SH PROTOCOLS
  25. This functionality affects all supported protocols
  26. .SH EXAMPLE
  27. .nf
  28. int main(void)
  29. {
  30. CURL *curl = curl_easy_init();
  31. if(curl) {
  32. CURLcode ret;
  33. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  34. /* refuse to download if larger than 1000 bytes! */
  35. curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 1000L);
  36. ret = curl_easy_perform(curl);
  37. }
  38. }
  39. .fi
  40. .SH AVAILABILITY
  41. Added in curl 7.10.8
  42. .SH RETURN VALUE
  43. Returns CURLE_OK if the size passed is valid or CURLE_BAD_FUNCTION_ARGUMENT if
  44. not.
  45. .SH SEE ALSO
  46. .BR CURLOPT_MAXFILESIZE_LARGE (3),
  47. .BR CURLOPT_MAX_RECV_SPEED_LARGE (3)