in aidial_adapter_openai/utils/resource.py [0:0]
def from_data_url(cls, data_url: str) -> Optional["Resource"]:
"""
Parsing a resource encoded as a data URL.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs for reference.
"""
type = cls.parse_data_url_content_type(data_url)
if type is None:
return None
data_base64 = data_url.removeprefix(cls._to_data_url_prefix(type))
return cls.from_base64(type, data_base64)