CURLOPT_INFILESIZE.3 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. .\" generated by cd2nroff 0.1 from CURLOPT_INFILESIZE.md
  2. .TH CURLOPT_INFILESIZE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_INFILESIZE \- size of the input file to send off
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE, long filesize);
  9. .fi
  10. .SH DESCRIPTION
  11. When uploading a file to a remote site, \fIfilesize\fP should be used to tell
  12. libcurl what the expected size of the input file is. This value must be passed
  13. as a long. See also \fICURLOPT_INFILESIZE_LARGE(3)\fP for sending files larger
  14. than 2GB.
  15. For uploading using SCP, this option or \fICURLOPT_INFILESIZE_LARGE(3)\fP is
  16. mandatory.
  17. To unset this value again, set it to \-1.
  18. Using \fICURLOPT_UPLOAD(3)\fP to an HTTP/1.1 server and this value set to \-1, makes
  19. libcurl do a chunked transfer\-encoded upload.
  20. When sending emails using SMTP, this command can be used to specify the
  21. optional SIZE parameter for the MAIL FROM command.
  22. This option does not limit how much data libcurl actually sends, as that is
  23. controlled entirely by what the read callback returns, but telling one value
  24. and sending a different amount may lead to errors.
  25. .SH DEFAULT
  26. Unset
  27. .SH PROTOCOLS
  28. This functionality affects all supported protocols
  29. .SH EXAMPLE
  30. .nf
  31. #define FILE_SIZE 12345L
  32. int main(void)
  33. {
  34. CURL *curl = curl_easy_init();
  35. if(curl) {
  36. long uploadsize = FILE_SIZE;
  37. curl_easy_setopt(curl, CURLOPT_URL,
  38. "ftp://example.com/destination.tar.gz");
  39. curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
  40. curl_easy_setopt(curl, CURLOPT_INFILESIZE, uploadsize);
  41. curl_easy_perform(curl);
  42. }
  43. }
  44. .fi
  45. .SH HISTORY
  46. SMTP support added in 7.23.0
  47. .SH AVAILABILITY
  48. Added in curl 7.1
  49. .SH RETURN VALUE
  50. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  51. .SH SEE ALSO
  52. .BR CURLINFO_CONTENT_LENGTH_UPLOAD_T (3),
  53. .BR CURLOPT_INFILESIZE_LARGE (3),
  54. .BR CURLOPT_UPLOAD (3)