MCPcopy Create free account
hub / github.com/AstrBotDevs/AstrBot / save

Method save

astrbot/api/web.py:112–128  ·  view source on GitHub ↗

Save the uploaded file to disk. Args: destination: Destination file path.

(self, destination: str | Path)

Source from the content-addressed store, hash-verified

110 return None
111
112 async def save(self, destination: str | Path) -> None:
113 """Save the uploaded file to disk.
114
115 Args:
116 destination: Destination file path.
117 """
118 path = Path(destination)
119 try:
120 await self._upload_file.seek(0)
121 except Exception:
122 pass
123 with path.open("wb") as output:
124 while True:
125 chunk = await self._upload_file.read(1024 * 1024)
126 if not chunk:
127 break
128 output.write(chunk)
129
130 async def read(self, size: int = -1) -> bytes:
131 """Read bytes from the uploaded file.

Callers 5

save_temp_imgFunction · 0.45
convert_image_to_jpegFunction · 0.45
_compress_image_syncFunction · 0.45
get_audioMethod · 0.45
_screenshot_to_bytesFunction · 0.45

Calls 4

seekMethod · 0.80
openMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected