Rework book example to support upload book photo.
This commit is contained in:
@@ -43,6 +43,18 @@ ResponsePtr ResponseBuilder::operator()() {
|
||||
return response;
|
||||
}
|
||||
|
||||
ResponseBuilder& ResponseBuilder::File(const webcc::Path& path,
|
||||
bool infer_media_type,
|
||||
std::size_t chunk_size) {
|
||||
body_.reset(new FileBody{ path, chunk_size });
|
||||
|
||||
if (infer_media_type) {
|
||||
media_type_ = media_types::FromExtension(path.extension().string());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ResponseBuilder& ResponseBuilder::Date() {
|
||||
headers_.push_back(headers::kDate);
|
||||
headers_.push_back(utility::GetTimestamp());
|
||||
|
||||
@@ -92,6 +92,11 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Use the file content as body.
|
||||
// NOTE: Error::kFileError might be thrown.
|
||||
ResponseBuilder& File(const webcc::Path& path, bool infer_media_type = true,
|
||||
std::size_t chunk_size = 1024);
|
||||
|
||||
ResponseBuilder& Header(const std::string& key, const std::string& value) {
|
||||
headers_.push_back(key);
|
||||
headers_.push_back(value);
|
||||
|
||||
Reference in New Issue
Block a user