5#ifndef MOLYBDEN_UPLOAD_DATA_HPP
6#define MOLYBDEN_UPLOAD_DATA_HPP
18enum UploadDataType { kByteData, kTextData, kFormData, kMultipartFormData };
46 std::shared_ptr<S>
as();
54 virtual UploadDataType
type()
const = 0;
62 static std::shared_ptr<ByteData> create(std::string
value);
67 virtual const std::string&
value()
const = 0;
80 static std::shared_ptr<TextData> create(std::string
value);
85 virtual std::string
value()
const = 0;
98 const std::string
key;
111 static std::shared_ptr<FormData> create(std::vector<FormDataPair> value);
117 virtual std::vector<FormDataPair>
pairs()
const = 0;
123enum MultipartFormDataPairValueType { kString, kFile };
147 std::shared_ptr<S>
as();
155 virtual MultipartFormDataPairValueType
type()
const = 0;
164 std::shared_ptr<MultipartFormDataPairValue>
value = {});
174 const std::shared_ptr<MultipartFormDataPairValue>
value;
180enum FileValueType { kPath, kBytes };
203 std::shared_ptr<S>
as();
211 virtual FileValueType
type()
const = 0;
219 static std::shared_ptr<FilePath> create(std::string
value);
224 virtual std::string
value()
const = 0;
232 static std::shared_ptr<FileBytes> create(std::string
value);
237 virtual const std::string&
value()
const = 0;
279 static std::shared_ptr<MultipartFormDataPairValueFile> create(
File value);
292 static std::shared_ptr<MultipartFormDataPairValueString> create(
298 virtual std::string
value()
const = 0;
306 static std::shared_ptr<MultipartFormData> create(
307 std::vector<MultipartFormDataPair> value);
313 virtual std::vector<MultipartFormDataPair>
pairs()
const = 0;
An upload data as a sequence of bytes.
Definition upload_data.hpp:60
virtual void swap(std::string *value)=0
Moves the upload data bytes to the given value.
virtual const std::string & value() const =0
Returns the upload data bytes or an empty string if the bytes were swapped.
The file bytes value.
Definition upload_data.hpp:230
virtual void swap(std::string *value)=0
Moves the file bytes to the given value.
virtual const std::string & value() const =0
Returns the file bytes or an empty string if the bytes were swapped.
The file path value.
Definition upload_data.hpp:217
virtual std::string value() const =0
Returns the absolute or relative file path.
The base class that all file value types must implement.
Definition upload_data.hpp:185
std::shared_ptr< S > as()
Casts this file value to the target type.
virtual FileValueType type() const =0
Returns the current file value type.
An upload data of the "text/plain" content type.
Definition upload_data.hpp:78
virtual std::string value() const =0
The text representation of the upload data.
An interface that all upload data implementations must extend.
Definition upload_data.hpp:23
std::shared_ptr< S > as()
Casts this upload data to the target type.
virtual UploadDataType type() const =0
Returns the current upload data type.
The file data.
Definition upload_data.hpp:255
std::string name
The file name including extension.
Definition upload_data.hpp:259
std::shared_ptr< FileValue > value
The file value.
Definition upload_data.hpp:271
std::string content_type
The content type determined by the file extension.
Definition upload_data.hpp:266