You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to async callback download image to memory and Download interface is not user-friendly for me.
so we have write callback for DownloadAsync method but we don't have DownloadCallback method where I could have response ctx or some sort where I could just do:
const auto buffer = std::make_shared<std::vector<uint8_t>>();
auto f = session->DownloadAsync( cpr::WriteCallback{
[buffer]( std::string_view data, intptr_t /*userdata*/, auto ctx ) -> bool
{
buffer->insert( buffer->end(), data.begin(), data.end() );
if ( ctx->finished && ctx->status_code == 200 )
{
//somelogic
}
return true;
} } );
or just DownloadCallback that accepts cpr::Response& and called when download finished where body has payload bytes
Currently, I don't know how conveniently do such thing.
session->GetDownloadFileLength() - it does request inside, so the logic is not async anymore
SetProgressCallback - sure we can use it but why do we need two callbacks to simply downloading file?
So am I missing something here to conveniently download the file in a callback way?
The text was updated successfully, but these errors were encountered:
I am trying to async callback download image to memory and Download interface is not user-friendly for me.
so we have write callback for DownloadAsync method but we don't have DownloadCallback method where I could have response ctx or some sort where I could just do:
or just DownloadCallback that accepts cpr::Response& and called when download finished where body has payload bytes
Currently, I don't know how conveniently do such thing.
session->GetDownloadFileLength() - it does request inside, so the logic is not async anymore
SetProgressCallback - sure we can use it but why do we need two callbacks to simply downloading file?
So am I missing something here to conveniently download the file in a callback way?
The text was updated successfully, but these errors were encountered: