From e846989a7ffe44f474b82c2c17d464ef41d6c1df Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 30 Jan 2020 19:30:21 -0500 Subject: [PATCH] Not finished updating dependencies. oatpp has changed --- 3rdparty/oatpp | 2 +- include/callback/StreamCallback.h | 2 +- include/controller/SongController.hpp | 32 +++++++++++++++++++++++---- src/manager/SongManager.cpp | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/3rdparty/oatpp b/3rdparty/oatpp index afbafe4..27c4644 160000 --- a/3rdparty/oatpp +++ b/3rdparty/oatpp @@ -1 +1 @@ -Subproject commit afbafe447ff447db5ab227022eb4a568da97d16b +Subproject commit 27c46444dbac6af79172b1600c7fcc99ff6df42b diff --git a/include/callback/StreamCallback.h b/include/callback/StreamCallback.h index 862c20a..2e216a5 100644 --- a/include/callback/StreamCallback.h +++ b/include/callback/StreamCallback.h @@ -4,7 +4,7 @@ #include #include "oatpp/core/data/stream/FileStream.hpp" -#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" +//#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" namespace callback { class StreamCallback : public oatpp::data::stream::ReadCallback { diff --git a/include/controller/SongController.hpp b/include/controller/SongController.hpp index e6311c7..dd93ceb 100644 --- a/include/controller/SongController.hpp +++ b/include/controller/SongController.hpp @@ -9,13 +9,15 @@ #include #include +#include #include "oatpp/core/data/stream/ChunkedBuffer.hpp" #include "oatpp/core/data/stream/FileStream.hpp" #include "oatpp/core/macro/codegen.hpp" #include "oatpp/core/macro/component.hpp" #include "oatpp/web/mime/multipart/InMemoryPartReader.hpp" #include "oatpp/web/mime/multipart/Reader.hpp" -#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" +//#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" +#include "oatpp/web/protocol/http/outgoing/StreamingBody.hpp" #include "oatpp/web/server/api/ApiController.hpp" #include "callback/StreamCallback.h" @@ -64,10 +66,10 @@ namespace controller { OATPP_ASSERT_HTTP(file, Status::CODE_400, "file is null"); - auto buff = std::unique_ptr(new char[file->getKnownSize()]); - auto buffSize = file->getInputStream()->read(buff.get(), file->getKnownSize()); + auto buff = std::make_unique(file->getInMemoryData()->c_str()); + auto buffSize = file->getKnownSize(); - std::vector data(buff.get(), buff.get() + buffSize); + std::vector data(*buff, *buff + buffSize); model::Song sng; sng.data = std::move(data); @@ -223,15 +225,37 @@ namespace controller { auto dSize = 1024; + /** + auto buff = std::make_unique(file->getInMemoryData()->c_str()); + auto buffSize = file->getKnownSize(); + + std::vector data(*buff, *buff + buffSize); + */ + + /** auto db = std::make_shared( std::make_shared(songDb.songPath), nullptr, dSize); + */ + /** + auto db = std::make_shared( + std::make_shared(songDb.songPath) + ); + */ + + auto db = std::make_shared( + std::make_shared(songDb.songPath), + dSize); + + /** auto response = OutgoingResponse::createShared(Status::CODE_200, db); response->putHeader(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE); response->putHeader(Header::CONTENT_TYPE, "audio/mpeg"); return response; + */ + return createResponse(Status::CODE_200, "Aye okay"); } #include OATPP_CODEGEN_END(ApiController) diff --git a/src/manager/SongManager.cpp b/src/manager/SongManager.cpp index 5ea7ac7..cd37aab 100644 --- a/src/manager/SongManager.cpp +++ b/src/manager/SongManager.cpp @@ -5,7 +5,7 @@ #include #include -#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" +//#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" #include "oatpp/web/server/api/ApiController.hpp" #include "database/CoverArtRepository.h"