10#include <unordered_map>
25 std::unordered_map<std::string, std::string>
fields;
28 std::vector<UploadedFile>
files;
void receive_multipart(const HttpRequest &req, std::shared_ptr< ResponseWriter > writer, std::function< void(MultipartUpload &)> on_complete, MultipartLimits limits={})
Receives a multipart/form-data body, streaming file parts to disk.
Represents an incoming HTTP request.
Definition HttpRequest.hpp:54
Limits for MultipartStreamParser. Exceeding one fails the parse (see MultipartStreamParser::failed())...
Definition MultipartStreamParser.hpp:14
The result of receive_multipart().
Definition MultipartUpload.hpp:24
std::vector< UploadedFile > files
Definition MultipartUpload.hpp:28
bool ok() const
Definition MultipartUpload.hpp:32
void discard()
Deletes every saved file (for example after rejecting the upload).
std::string error
Empty on success. On failure no files are left on disk.
Definition MultipartUpload.hpp:30
std::unordered_map< std::string, std::string > fields
Definition MultipartUpload.hpp:25
A file part saved to disk by receive_multipart().
Definition MultipartUpload.hpp:16
std::string path
Where the file was saved (owner-only permissions).
Definition MultipartUpload.hpp:20
std::string filename
Chosen by the client: never use it as a path.
Definition MultipartUpload.hpp:18
std::string content_type
As sent by the client.
Definition MultipartUpload.hpp:19
std::string field
The form field name.
Definition MultipartUpload.hpp:17