Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
MultipartUpload.hpp
Go to the documentation of this file.
1#pragma once
6
7#include <functional>
8#include <memory>
9#include <string>
10#include <unordered_map>
11#include <vector>
12
13namespace orbit::http {
14
17 std::string field;
18 std::string filename;
19 std::string content_type;
20 std::string path;
21};
22
25 std::unordered_map<std::string, std::string> fields;
28 std::vector<UploadedFile> files;
30 std::string error;
31
32 bool ok() const { return error.empty(); }
34 void discard();
35};
36
64void receive_multipart(const HttpRequest& req, std::shared_ptr<ResponseWriter> writer,
65 std::function<void(MultipartUpload&)> on_complete, MultipartLimits limits = {});
66
67} // namespace http
Definition Task.hpp:10
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