Uploading files

Uploading files requires the use Multipart, with xxhr this is really simple.

Given a web server expecting a field named somefile an xxhr::File or xxhr::Buffer can be passed as in the following example.

POST("http://httpbin.org/post"s,
Multipart{
{"somefile", File{"../../../xxhr/api.hpp"} }
},
on_response = [](auto&& resp) {
std::cout << resp.text;
std::cout << "Upload status : " << resp.error << " - " << resp.status_code << "\n";
});

Multiple files at once

It is possible, as it is a Multipart query to add many xxhr::File or xxhr::Buffer.

auto buffer = "this is some buffer"s;
POST("http://httpbin.org/post"s,
Multipart{
{"somefile", File{"../../../xxhr/api.hpp"} }
, {"other", File{"../../../xxhr/multipart.hpp"} }
, {"and_another", File{"../../../README.md"} }
, {"somebuffer", Buffer{buffer.begin(), buffer.end(), "IN_MEMORY_FILE"} }
},
xxhr::on_response
constexpr make_handler_t< on_response_ > on_response
Continuation callback ( i.e. signature : void callback(xxhr::Response)) for the asynchronous HTTP ope...
Definition: handler.hpp:39
xxhr::POST
void POST(Ts &&... ts)
HTTP POST Request.
Definition: api.hpp:47