jpbarrette / curlpp

C++ wrapper around libcURL
http://www.curlpp.org
1.68k stars 360 forks source link

[question]how to use progressfunction to get upload or download progress value #155

Closed xuyiqun-learner closed 1 year ago

xuyiqun-learner commented 1 year ago

is the same usage of ReadFucnction as ProgressFunction that to get progress value in the example02 ?

sgallou commented 1 year ago

If the question is to know how to use ProgressFunction, I currently use this code (file download) :

request.setOpt<curlpp::options::ProgressFunction>(
   [&location, &reporter](const double totalDownloaded, const double currentlyDownloaded, double, double)-> int
   {
      if (totalDownloaded != 0.0)
         reporter(location.string(), static_cast<float>(currentlyDownloaded * 100.0l / totalDownloaded));
      return CURL_PROGRESSFUNC_CONTINUE;
   });

Full code available here

xuyiqun-learner commented 1 year ago

thanks