Reputation: 55
I want to get a .bmp format image via HTTP request. When I send a test request via Postman there are headlines added such as Content-Type and when the request is saved to the stream they are automatically added to the generated .bmp file and the file doesn’t work properly. When I remove not needed headlines by hand in Nano the image can be opened the way I expect it to be.
Is there a way in cpprestsdk to not add the headlines and post only the image file or the headlines need to be deleted?
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--
Upvotes: 0
Views: 598
Reputation: 16
According to the documentation(https://github.com/Microsoft/cpprestsdk/wiki/Getting-Started-Tutorial), there is no such way, so you should remove the headers yourself.
Upvotes: 0