GNURLOPT_RESUME_FROM(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_RESUME_FROM(3) β€” curl_easy_setopt options πŸŽ€

okay bestie so this is a page from the curl_easy_setopt options manual, and it's literally all about picking the exact byte where your transfer starts. it's giving "skip to the good part" energy ✨


✨ NAME ✨

CURLOPT_RESUME_FROM β€” set a point to resume transfer from 🫢


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESUME_FROM, long from);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so you pass a long as the parameter, and it holds the offset β€” in number of bytes β€” that you want the transfer to start from. that's it, that's the whole vibe πŸ’…

set this option to 0 and your transfer starts from the very beginning (which, lowkey, just means resume is effectively turned off). for FTP though? set it to -1 and the transfer starts from the end of the target file β€” super handy when you wanna continue an interrupted upload πŸ‘‘

and when you're doing uploads with FTP, the resume position is where in the local/source file libcurl should try to pick the upload back up from β€” and then it'll append the source file to the remote target file. no cap. πŸ”₯

heads up bestie: if you need to resume a transfer beyond the 2GB limit, use CURLOPT_RESUME_FROM_LARGE(3) instead. the regular one just can't hold that much, iykyk 😭

πŸŽ€ DEFAULT πŸŽ€

0, not used


🌈 PROTOCOLS 🌈

HTTP, FTP, SFTP, FILE


⭐ EXAMPLE ⭐

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");

  /* resume upload at byte index 200 */
  curl_easy_setopt(curl, CURLOPT_RESUME_FROM, 200L);

  /* ask for upload */
  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);

  /* set total data amount to expect */
  curl_easy_setopt(curl, CURLOPT_INFILESIZE, size_of_file);

  /* Perform the request */
  curl_easy_perform(curl);
}

like, look at her go 🧚 she's resuming at byte index 200 and asking for an upload and setting the total data amount to expect β€” main character energy fr fr πŸ’œ


πŸ“ AVAILABILITY πŸ“

Always ✨ (yes, always. she's been here the whole time.)


πŸ’– RETURN VALUE πŸ’–

Returns CURLE_OK 🫢


πŸ”₯ SEE ALSO πŸ”₯


aaaand that's the page, bestie πŸ’… this was libcurl 7.37.0, dated 17 Jun 2014 β€” go forth and resume slayfully πŸŒΈπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from