33import logging
44import ssl
55import time
6+ from io import BytesIO
67from pathlib import Path
78from typing import Any , Dict , List , Mapping , NoReturn , Optional , Tuple , Union
89
@@ -114,14 +115,14 @@ async def storage_push(self, content: Mapping) -> str:
114115 resp .raise_for_status ()
115116 return (await resp .json ()).get ("hash" )
116117
117- async def ipfs_push_file (self , file_content : Union [ str , bytes ] ) -> str :
118+ async def ipfs_push_file (self , file_content : bytes ) -> str :
118119 """
119120 Push a file to the IPFS service.
120121
121122 :param file_content: The file content to upload
122123 """
123124 data = aiohttp .FormData ()
124- data .add_field ("file" , file_content )
125+ data .add_field ("file" , BytesIO ( file_content ) )
125126
126127 url = "/api/v0/ipfs/add_file"
127128 logger .debug (f"Pushing file to IPFS on { url } " )
@@ -135,7 +136,7 @@ async def storage_push_file(self, file_content) -> str:
135136 Push a file to the storage service.
136137 """
137138 data = aiohttp .FormData ()
138- data .add_field ("file" , file_content )
139+ data .add_field ("file" , BytesIO ( file_content ) )
139140
140141 url = "/api/v0/storage/add_file"
141142 logger .debug (f"Posting file on { url } " )
@@ -669,7 +670,7 @@ async def _storage_push_file_with_message(
669670 content_type = "application/json" ,
670671 )
671672 # Add the file
672- data .add_field ("file" , file_content )
673+ data .add_field ("file" , BytesIO ( file_content ) )
673674
674675 url = "/api/v0/storage/add_file"
675676 logger .debug (f"Posting file on { url } " )
0 commit comments