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

Method to_bytes

astrbot/core/utils/media_utils.py:739–750  ·  view source on GitHub ↗

Resolve media, read bytes, and clean resolver-owned temp files.

(
        self,
        *,
        target_format: str | None = None,
        preserve_mp3: bool = False,
    )

Source from the content-addressed store, hash-verified

737 return str(resolved.path.resolve())
738
739 async def to_bytes(
740 self,
741 *,
742 target_format: str | None = None,
743 preserve_mp3: bool = False,
744 ) -> bytes:
745 """Resolve media, read bytes, and clean resolver-owned temp files."""
746 async with self.as_path(
747 target_format=target_format,
748 preserve_mp3=preserve_mp3,
749 ) as resolved:
750 return resolved.read_bytes()
751
752 async def to_base64(
753 self,

Calls 2

as_pathMethod · 0.95
read_bytesMethod · 0.80