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

Method to_data_url

astrbot/core/utils/media_utils.py:851–866  ·  view source on GitHub ↗

Resolve media directly to a provider-ready data URL.

(
        self,
        *,
        strict: bool = False,
        target_format: str | None = None,
        preserve_mp3: bool = False,
        default_mime_type: str | None = "image/jpeg",
    )

Source from the content-addressed store, hash-verified

849 )
850
851 async def to_data_url(
852 self,
853 *,
854 strict: bool = False,
855 target_format: str | None = None,
856 preserve_mp3: bool = False,
857 default_mime_type: str | None = "image/jpeg",
858 ) -> str | None:
859 """Resolve media directly to a provider-ready data URL."""
860 resolved = await self.to_base64_data(
861 strict=strict,
862 target_format=target_format,
863 preserve_mp3=preserve_mp3,
864 default_mime_type=default_mime_type,
865 )
866 return resolved.to_data_url() if resolved else None
867
868 @asynccontextmanager
869 async def open(

Callers 9

_image_to_data_urlMethod · 0.45
assemble_contextMethod · 0.45
encode_image_bs64Method · 0.45
resolve_image_partMethod · 0.45
resolve_audio_partMethod · 0.45
encode_image_bs64Method · 0.45
prepare_audio_inputFunction · 0.45

Calls 1

to_base64_dataMethod · 0.95

Tested by

no test coverage detected