Created simple gui for uploading a song and implemented the functionality. #1 and #2

This commit is contained in:
amazing-username
2019-03-23 21:17:24 -04:00
parent 99e35217eb
commit e81b4ecdb1
7 changed files with 90 additions and 37 deletions
+10 -6
View File
@@ -12,6 +12,9 @@ using std::string;
using json = nlohmann::json;
using Managers::FileManager;
using Models::UploadForm;
using namespace cpr;
namespace Syncers
@@ -20,22 +23,23 @@ namespace Syncers
Upload::Upload(string filePath)
{
this->songPath = filePath;
this->fMgr = Managers::FileManager(songPath);
this->fMgr = FileManager(songPath);
}
Upload::Upload(UploadForm formData)
{
this->url = formData.url;
this->songPath = formData.filePath;
}
void Upload::uploadSong()
{
configureSongDemo();
string url = apiUrl + ":" + std::to_string(port) + apiEndPoint;
try
{
auto r = cpr::Post(cpr::Url{url},
cpr::Multipart{{"key", "small value"},
{"file", cpr::File{songPath}}});
cout << r.text << std::endl;
cout << r.status_code<< std::endl;
cout<<"Success"<<endl;
}
+3
View File
@@ -7,6 +7,7 @@
#include"Managers/FileManager.h"
#include"Models/Song.h"
#include"Models/UploadForm.h"
namespace Syncers
@@ -16,6 +17,7 @@ namespace Syncers
public:
Upload();
Upload(std::string);
Upload(Models::UploadForm);
void uploadSong();
@@ -25,6 +27,7 @@ namespace Syncers
std::string apiUrl{"http://192.168.1.3"};
std::string apiEndPoint{"/api/song/data"};
std::string songPath;
std::string url;
int port{9349};
void configureSongDemo();