@@ -393,6 +393,11 @@ svr.Post("/multipart", [&](const auto& req, auto& res) {
393
393
<< " (" << file.content_type << ") - "
394
394
<< file.content.size() << " bytes" << std::endl;
395
395
396
+ // Access additional headers if needed
397
+ for (const auto& header : file.headers) {
398
+ std::cout << "Header: " << header.first << " = " << header.second << std::endl;
399
+ }
400
+
396
401
// Save to disk
397
402
std::ofstream ofs(file.filename, std::ios::binary);
398
403
ofs << file.content;
@@ -430,22 +435,6 @@ svr.Post("/multipart", [&](const auto& req, auto& res) {
430
435
});
431
436
```
432
437
433
- #### Legacy API (still supported)
434
-
435
- > ** Note** : The ` req.files ` field has been removed. Use ` req.form.files ` and ` req.form.fields ` instead.
436
- > For backward compatibility, ` req.get_file_value() ` , ` req.has_file() ` , and ` req.get_file_values() ` methods are still available and will delegate to the new ` req.form ` API.
437
-
438
- ``` cpp
439
- svr.Post(" /multipart" , [&](const auto & req, auto & res) {
440
- // Legacy API - still works but delegates to req.form internally
441
- auto ret = req.has_file("name1"); // -> req.form.has_file("name1")
442
- const auto& file = req.get_file_value("name1"); // -> req.form.get_file("name1")
443
- // file.filename;
444
- // file.content_type;
445
- // file.content;
446
- });
447
- ```
448
-
449
438
### Receive content with a content receiver
450
439
451
440
``` cpp
@@ -454,9 +443,9 @@ svr.Post("/content_receiver",
454
443
if (req.is_multipart_form_data()) {
455
444
// NOTE: `content_reader` is blocking until every form data field is read
456
445
// This approach allows streaming processing of large files
457
- MultipartFormDataItems items;
446
+ FormFileItems items;
458
447
content_reader (
459
- [&](const MultipartFormData &item) {
448
+ [&](const FormFile &item) {
460
449
items.push_back(item);
461
450
return true;
462
451
},
@@ -781,7 +770,7 @@ auto res = cli.Post("/post", params);
781
770
### POST with Multipart Form Data
782
771
783
772
``` c++
784
- httplib::MultipartFormDataItems items = {
773
+ httplib::FormDataInputItems items = {
785
774
{ "text1", "text default", "", "" },
786
775
{ "text2", "aωb", "", "" },
787
776
{ "file1", "h\ne\n\nl\nl\no\n", "hello.txt", "text/plain" },
0 commit comments