summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-07-23 18:34:58 +0300
committerMaxim Devaev <[email protected]>2022-07-24 05:38:26 +0300
commit0e3ebac3627fe5039957d2d48d68d8620ff9384f (patch)
tree2792d2c261edffedf8bd8675f6ad8a5ea1bb56a3 /kvmd/apps
parentde140537254a517559c78de048791a197011c1f6 (diff)
reading images api
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/kvmd/api/msd.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/kvmd/apps/kvmd/api/msd.py b/kvmd/apps/kvmd/api/msd.py
index 7347bd8c..e9e1e68b 100644
--- a/kvmd/apps/kvmd/api/msd.py
+++ b/kvmd/apps/kvmd/api/msd.py
@@ -84,6 +84,18 @@ class MsdApi:
# =====
+ @exposed_http("GET", "/msd/read")
+ async def __read_handler(self, request: Request) -> StreamResponse:
+ name = valid_msd_image_name(request.query.get("image"))
+ async with self.__msd.read_image(name) as size:
+ response = await start_streaming(request, "application/octet-stream", size, name)
+ while True:
+ chunk = await self.__msd.read_image_chunk()
+ if not chunk:
+ return response
+ await response.write(chunk)
+ return response
+
@exposed_http("POST", "/msd/write")
async def __write_handler(self, request: Request) -> Response:
name = valid_msd_image_name(request.query.get("image"))