【发布时间】:2021-11-16 06:05:19
【问题描述】:
我想通过 HTTP 请求获取 .bmp 格式的图像。当我通过 Postman 发送测试请求时,会添加诸如 Content-Type 之类的标题,当请求保存到流时,它们会自动添加到生成的 .bmp 文件中,并且文件无法正常工作。当我在 Nano 中手动删除不需要的标题时,图像可以按我预期的方式打开。
cpprestsdk有没有办法不加标题,只发图片文件或者标题需要删除?
void Service::handlePost(http_request request)
{
auto fileStream = std::make_sharde<Concurrency::streams::ostream>();
utility::string_t file = "file.bmp";
// open stream to output file
*fileStream = Concurrency::streams::fstream::open_stream(file).get();
request.body().read_to_end(fileStream->streambuf()).wait();
fileStream.close();
//...
}
------------------------------553993878653478454105895
Content-Disposition: form-data; name="image"; filename="file.bmp"
Content-Type: image/bmp
BM /^@^@^@^@^@^@^@^@
(BMP binary file)
^@^@^@^@^@^@^@
------------------------------553993878653478454105895--
【问题讨论】:
标签: c++ visual-studio rest vspackage cpprest-sdk