@@ -90,7 +90,7 @@ svr.Post("/multipart", [&](const auto& req, auto& res) {
9090 const auto& file = req.get_file_value("name1");
9191 // file.filename;
9292 // file.content_type;
93- auto body = req.body.substr( file.offset, file.length) ;
93+ // file.content ;
9494});
9595
9696```
@@ -118,12 +118,26 @@ svr.Get("/stream", [&](const Request &req, Response &res) {
118118``` cpp
119119svr.Post(" /content_receiver" ,
120120 [&](const Request &req, Response &res, const ContentReader &content_reader) {
121- std::string body;
122- content_reader ([ &] (const char * data, size_t data_length) {
123- body.append(data, data_length);
124- return true;
125- });
126- res.set_content(body, "text/plain");
121+ if (req.is_multipart_form_data()) {
122+ MultipartFiles files;
123+ content_reader (
124+ [&](const std::string &name, const char *data, size_t data_length) {
125+ auto &file = files.find(name)->second;
126+ file.content.append(data, data_length);
127+ return true;
128+ },
129+ [&](const std::string &name, const MultipartFile &file) {
130+ files.emplace(name, file);
131+ return true;
132+ });
133+ } else {
134+ std::string body;
135+ content_reader ([ &] (const char * data, size_t data_length) {
136+ body.append(data, data_length);
137+ return true;
138+ });
139+ res.set_content(body, "text/plain");
140+ }
127141 });
128142```
129143
0 commit comments