@@ -106,9 +106,7 @@ def __init__(self, image: str | BytesIO | bytes):
106106 super ().__init__ ("image" )
107107 self .image : str | BytesIO | bytes = image
108108
109- async def get_image (
110- self , headers : dict [str , None ] | None = None
111- ) -> BytesIO | bytes :
109+ async def get_image (self , headers : dict [str , Any ] | None = None ) -> BytesIO | bytes :
112110 if isinstance (self .image , str ):
113111 self .image = await self .curl_image (headers )
114112 return self .image
@@ -123,7 +121,8 @@ async def curl_image(self, extra_headers: dict | None = None) -> bytes:
123121 async with session .get (self .image ) as response :
124122 if response .status != 200 :
125123 raise ValueError (f"Failed to download image from { self .image } " )
126- obj = await response .read ()
124+ bt = await response .read ()
125+ obj = base64 .b64encode (bt )
127126 return obj
128127 raise ValueError ("Image must be a URL to use this method" )
129128
@@ -135,7 +134,7 @@ def get_content(self) -> str:
135134 image_type = get_image_format (self .image )
136135 if not image_type :
137136 return "[Unsupported image format]"
138- return f" .decode ()} )"
137+ return f"} )"
139138
140139 async def save_to (self , path : Path , headers : dict | None = None ):
141140 async with aiofiles .open (path , "wb" ) as f :
0 commit comments