class DemoApiClient : public oatpp::web::client::ApiClient {
#include OATPP_CODEGEN_BEGIN(ApiClient)
API_CLIENT_INIT(DemoApiClient)
public:
std::shared_ptr<Response> PutFile(
const oatpp::String& Path,
const std::map<oatpp::String, oatpp::String>& Headers,
const oatpp::String& LocalFilePath
)
{
std::ifstream inputFile(LocalFilePath);
std::string data;
inputFile >> data;
inputFile.close();
oatpp::web::client::ApiClient::Headers headers;
for (auto& head : Headers)
{
headers.put(head.first, head.second);
}
std::shared_ptr<oatpp::web::protocol::http::outgoing::Body> body;
body = oatpp::web::protocol::http::outgoing::BufferBody::createShared(
data,
"application/octet-stream"
);
return m_requestxecutor->execute("PUT", Path, headers, body, nullptr);
}
#include OATPP_CODEGEN_END(ApiClient)
};
oatpp客户端上传文件
最新推荐文章于 2024-10-03 17:00:00 发布