aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src
diff options
context:
space:
mode:
Diffstat (limited to 'solo-tool-project/src')
-rw-r--r--solo-tool-project/src/solo_tool/session_manager.py3
-rw-r--r--solo-tool-project/src/solo_tool/storage.py12
2 files changed, 15 insertions, 0 deletions
diff --git a/solo-tool-project/src/solo_tool/session_manager.py b/solo-tool-project/src/solo_tool/session_manager.py
index 96b100a..5dcb91f 100644
--- a/solo-tool-project/src/solo_tool/session_manager.py
+++ b/solo-tool-project/src/solo_tool/session_manager.py
@@ -50,3 +50,6 @@ class SessionManager():
def saveRecording(self, recording: Path, destination: str) -> None:
self._backend.writeRecording(recording, destination)
+
+ def uploadSong(self, song: Path, destination: str) -> None:
+ self._backend.writeSong(song, destination)
diff --git a/solo-tool-project/src/solo_tool/storage.py b/solo-tool-project/src/solo_tool/storage.py
index d07ba25..4d82504 100644
--- a/solo-tool-project/src/solo_tool/storage.py
+++ b/solo-tool-project/src/solo_tool/storage.py
@@ -25,6 +25,10 @@ class StorageBackend(Protocol):
raise NotImplementedError
@abstractmethod
+ def writeSong(self, song: Path, destination: str) -> None:
+ raise NotImplementedError
+
+ @abstractmethod
def listSongs(self) -> list[str]:
raise NotImplementedError
@@ -47,6 +51,9 @@ class FileSystemStorageBackend(StorageBackend):
def writeRecording(self, recording: Path, destination: str) -> None:
pass
+ def writeSong(self, song: Path, destination: str) -> None:
+ pass
+
def listSongs(self) -> list[str]:
return [str(Path(f).absolute()) for f in glob(str(self._storagePath / "songs" / "*"))]
@@ -77,6 +84,11 @@ class FileBrowserStorageBackend(StorageBackend):
with open(recording, "rb") as file:
self._request("POST", url, {"Content-Type" : "audio/mpeg"}, data=file)
+ def writeSong(self, song: Path, destination: str) -> None:
+ url = f"{self._baseUrl}/api/resources/songs/{destination}"
+ with open(song, "rb") as file:
+ self._request("POST", url, {}, data=file)
+
def listSongs(self) -> list[str]:
url = f"{self._baseUrl}/api/resources/songs"
response = self._request("GET", url)