22#include "anch-rest-common-export.hpp"
32#include "codec/mediaType.hpp"
34#include "rest/headers.hpp"
79 class ANCH_REST_COMMON_EXPORT
Part {
90 std::optional<std::string> _filename;
99 mutable std::string _content;
102 std::shared_ptr<const FileContent> _file;
105 mutable bool _loaded;
147 std::optional<std::string_view> filename = std::nullopt);
162 std::optional<std::string_view> filename);
181 std::unique_ptr<std::istream>
open()
const;
188 std::size_t
size() const noexcept;
209 std::optional<std::filesystem::path>
getPath() const;
218 bool operator==(const
Part& other) const;
287 class ANCH_REST_COMMON_EXPORT
Form {
292 std::vector<anch::rest::Part> _parts;
313 Form&
add(std::string_view name, std::string value);
343 bool has(std::string_view name)
const noexcept;
352 std::optional<std::string_view>
field(std::string_view name)
const;
361 std::vector<std::string_view>
fields(std::string_view name)
const;
379 std::vector<const anch::rest::Part*>
parts(std::string_view name)
const;
386 std::size_t
size() const noexcept;
void setName(std::string_view name)
static Part fromFile(std::string_view name, const std::filesystem::path &path, anch::codec::MediaType mediaType, std::optional< std::string_view > filename=std::nullopt)
std::optional< std::filesystem::path > getPath() const
anch::rest::Headers & getHeaders() noexcept
void setMediaType(anch::codec::MediaType mediaType)
std::size_t size() const noexcept
std::unique_ptr< std::istream > open() const
static Part fromTemporaryFile(std::string_view name, const std::filesystem::path &path, anch::codec::MediaType mediaType, std::optional< std::string_view > filename)
bool isFile() const noexcept
bool isInMemory() const noexcept
const anch::codec::MediaType & getMediaType() const noexcept
const std::string & getName() const noexcept
Part(std::string_view name, std::string content)
Part(std::string_view name, std::string_view filename, anch::codec::MediaType mediaType, std::string content)
std::string_view content() const
std::optional< std::string_view > getFilename() const noexcept
AnCH codec library namespace.
Definition csv.hpp:31
AnCH REST library namespace.
Definition auth.hpp:29
AnCH framework base namespace.
Definition app.hpp:30