I’m trying to send a POST request containing multiple binary files to a HTTP server. The server interprets the request using cgicc.
For a single file, it works like this:
cgicc::Cgicc cgi;
cgicc::const_file_iterator file;
file = cgi.getFile("file_1");
if(file != cgi.getFiles().end())
{
std::stringstream stringStream;
file->writeToStream(stringStream);
//do whatever with stringStream
}
Now, let’s say that I want to post multiple files and I don’t know the names of the attachments in advance in order to call cgi.getFile("file_x") for each file, is there any way to iterate over all of them? For the GET parameters, I can do this:
cgicc::Cgicc cgi;
const std::vector<cgicc::FormEntry> &formElements = cgi.getElements();
for (std::vector<cgicc::FormEntry>::const_iterator i = formElements.begin(); i != formElements.end(); ++i)
{
//process each (*i)
}
I’ve figured it out (it was obvious, but poorly documented):