diff options
| author | Eddy Pedroni <epedroni@pm.me> | 2026-10-05 10:22:17 +0200 |
|---|---|---|
| committer | Eddy Pedroni <epedroni@pm.me> | 2026-10-05 10:22:17 +0200 |
| commit | 63bb234f668eeab3d43ce57ce98842115b0fd8b0 (patch) | |
| tree | 1d53c63dd969534d08f72477d8edd0ff648aa50f | |
| parent | 9b223849e889adb162504b7ee7ab630a0dacabba (diff) | |
Skeleton implementation of song uploadupload-song
| -rw-r--r-- | solo-tool-project/src/solo_tool/session_manager.py | 3 | ||||
| -rw-r--r-- | solo-tool-project/src/solo_tool/storage.py | 12 | ||||
| -rw-r--r-- | web-project/src/solo_tool_web.py | 5 |
3 files changed, 20 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) diff --git a/web-project/src/solo_tool_web.py b/web-project/src/solo_tool_web.py index 98cb9df..544f23d 100644 --- a/web-project/src/solo_tool_web.py +++ b/web-project/src/solo_tool_web.py @@ -80,6 +80,11 @@ def sessionPage(sessionId: str): ui.icon('music_note') with ui.item_section(): ui.item_label(basename(song)) + with ui.item(on_click=lambda: None): + with ui.item_section().props('avatar'): + ui.icon('upload') + with ui.item_section(): + ui.item_label('Upload') # Header with ui.header().classes('items-center justify-between'): |
