Refine files upload.

This commit is contained in:
Chunting Gu
2019-04-10 13:48:33 +08:00
parent ba705e930e
commit 5f9532759e
11 changed files with 207 additions and 140 deletions
-28
View File
@@ -103,34 +103,6 @@ void ExampleImage(const std::string& path) {
ofs << r->content();
}
// Post/upload files.
void ExamplePostFiles() {
webcc::HttpClientSession session;
auto r = session.Request(webcc::HttpRequestBuilder{}
.Post()
.Url("http://httpbin.org/post")
.FileData("file1", "report.xls", "<xls report data>", "application/vnd.ms-excel")
.FileData("file2", "report.xml", "<xml report data>", "text/xml")());
std::cout << r->content() << std::endl;
}
// Post/upload files by file path.
void ExamplePostFiles(const std::string& url,
const std::string& name,
const std::string& file_name,
const std::string& file_path,
const std::string& content_type) {
webcc::HttpClientSession session;
auto r = session.Request(webcc::HttpRequestBuilder{}.Post().
Url(url).
File(name, file_name, file_path, content_type)());
std::cout << r->content() << std::endl;
}
int main() {
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);