diff --git a/changelog/1.3.0.md b/changelog/1.3.0.md index e046e625..341e1f90 100644 --- a/changelog/1.3.0.md +++ b/changelog/1.3.0.md @@ -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, 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.