I tried using the posted answer but found that it did not work well with express' json parser and it would give a bad request each time. I think using curlpp's form data is most likely the best option. See the code below for a basic example of sending a json string and a file in the form:
std::string BasicFormDataPost(std::string url, std::string body1, std::string filename)
{
std::ostringstream result;
try
{
// Initialization
curlpp::Cleanup cleaner;
curlpp::Easy request;
curlpp::Forms formParts;
formParts.push_back(new curlpp::FormParts::Content("formjson",body1)); // One has to remember to JSON.parse on the server to use the body data.
formParts.push_back(new curlpp::FormParts::File("attachment", filename));
using namespace curlpp::Options;
// request.setOpt(new Verbose(true));
request.setOpt(new Url(url));
request.setOpt(new HttpPost(formParts));
request.setOpt(WriteStream(&result));
request.perform();
return std::string( result.str());
}
catch ( curlpp::LogicError & e )
{
std::cout << e.what() << std::endl;
}
catch ( curlpp::RuntimeError & e )
{
std::cout << e.what() << std::endl;
}
}
This answer was pieced together from the previous answer and the curlpp examples located at: https://github.com/datacratic/curlpp/tree/master/examples