Improvement for Multipart Form Data

This commit is contained in:
yhirose committed 2026-02-20 23:15:01 -05:00
1 parent 43cf1822c6
commit 2280f1d191
3 files changed
+216 -12

No files matched your search

+11
View File
@@ -989,6 +989,17 @@ httplib::UploadFormDataItems items = {
auto res = cli.Post("/multipart", items);
```
To upload files from disk without loading them entirely into memory, use `make_file_provider`. The file is read and sent in chunks with a correct `Content-Length` header.
```cpp
httplib::FormDataProviderItems providers = {
httplib::make_file_provider("file1", "/path/to/large.bin", "large.bin", "application/octet-stream"),
httplib::make_file_provider("avatar", "/path/to/photo.jpg", "photo.jpg", "image/jpeg"),
};
auto res = cli.Post("/upload", {}, {}, providers);
```
### PUT
```c++