We are using libcurl
C API in order to send a file over SFTP. This works fine using a code like this :
....
fd = fopen(local_file_full_path.c_str(), "rb");
if (!fd)
{
cout << "Error opening local file: " << local_file_full_path << endl;
return -1;
}
curl_easy_setopt(curl_easy_handle, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl_easy_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl_easy_handle, CURLOPT_READDATA, fd);
curl_easy_setopt(curl_easy_handle, CURLOPT_HTTPHEADER, headerList);
However, that means that even though we have our data available - we have to write them into a file, and then pass the file over.
I was wondering if libcurl
provides an option in which, we could pass a stream of data, eg a pointer into a struct of our data. If that's the case, is there any example I could use? And does that mean changes are needed on the "receiver" end - as we don't own it.