mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Merge branch 'master' into data_resources
This commit is contained in:
commit
cc2e1e98a9
@ -13,6 +13,7 @@ Contents:
|
||||
- [Request Data Bundle](#request-data-bundle)
|
||||
- [ConnectionProviderSwitch](#connectionproviderswitch)
|
||||
- [Proper Server Stoppage](#proper-server-stoppage)
|
||||
- [TemporaryFile](#temporaryfile)
|
||||
- [Response::getBody()](#responsegetbody)
|
||||
- [data::stream::FIFOStream](#datastreamfifostream)
|
||||
- [data::stream::BufferedInputStream](#datastreambufferedinputstream)
|
||||
@ -240,6 +241,30 @@ Fix to [#476](https://github.com/oatpp/oatpp/issues/476), [#269](https://github.
|
||||
|
||||
Now call to `HttpConnectionHandler::stop()`, `AsyncHttpConnectionHandler::stop()` will shutdown all opened connections and will wait until all request handlers exit.
|
||||
|
||||
## TemporaryFile
|
||||
|
||||
Introduce `oatpp::data::share::TemporaryFile`.
|
||||
|
||||
Use-case:
|
||||
|
||||
Temporary file resolves concurrency issues during file uploads.
|
||||
Also, a temporary file ensures that partially uploaded (due to errors/exceptions) resources will be automatically deleted at the end of the block.
|
||||
|
||||
```cpp
|
||||
ENDPOINT("POST", "/upload", upload,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
oatpp::data::share::TemporaryFile tmp("/tmp"); // create random file in '/tmp' folder
|
||||
|
||||
auto stream = tmp.openOutputStream();
|
||||
request->transferBody(&stream); // transfer body to temporary file
|
||||
|
||||
tmp.moveFile("/path/to/permanent/storage/avatar.png"); // move file to permanent storage
|
||||
|
||||
return createResponse(Status::CODE_200, "OK");
|
||||
}
|
||||
```
|
||||
|
||||
## Response::getBody()
|
||||
|
||||
`oatpp::web::protocol::http::outgoing::Response` has a new method `getBody()` to retreive the body of the response.
|
||||
|
Loading…
Reference in New Issue
Block a user