mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-22 20:58:30 +00:00
Improved multipart form data interface
This commit is contained in:
parent
151ccba57e
commit
5324b3d661
3 changed files with 34 additions and 40 deletions
11
README.md
11
README.md
|
@ -119,15 +119,14 @@ svr.Get("/stream", [&](const Request &req, Response &res) {
|
|||
svr.Post("/content_receiver",
|
||||
[&](const Request &req, Response &res, const ContentReader &content_reader) {
|
||||
if (req.is_multipart_form_data()) {
|
||||
MultipartFiles files;
|
||||
MultipartFormDataItems files;
|
||||
content_reader(
|
||||
[&](const std::string &name, const MultipartFile &file) {
|
||||
files.emplace(name, file);
|
||||
[&](const MultipartFormData &file) {
|
||||
files.push_back(file);
|
||||
return true;
|
||||
},
|
||||
[&](const std::string &name, const char *data, size_t data_length) {
|
||||
auto &file = files.find(name)->second;
|
||||
file.content.append(data, data_length);
|
||||
[&](const char *data, size_t data_length) {
|
||||
files.back().content.append(data, data_length);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue