Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/aleph/sdk/client/authenticated_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import ssl
import time
from io import BytesIO
from pathlib import Path
from typing import Any, Dict, List, Mapping, NoReturn, Optional, Tuple, Union

Expand Down Expand Up @@ -114,14 +115,14 @@ async def storage_push(self, content: Mapping) -> str:
resp.raise_for_status()
return (await resp.json()).get("hash")

async def ipfs_push_file(self, file_content: Union[str, bytes]) -> str:
async def ipfs_push_file(self, file_content: bytes) -> str:
"""
Push a file to the IPFS service.

:param file_content: The file content to upload
"""
data = aiohttp.FormData()
data.add_field("file", file_content)
data.add_field("file", BytesIO(file_content))

url = "/api/v0/ipfs/add_file"
logger.debug(f"Pushing file to IPFS on {url}")
Expand All @@ -130,12 +131,12 @@ async def ipfs_push_file(self, file_content: Union[str, bytes]) -> str:
resp.raise_for_status()
return (await resp.json()).get("hash")

async def storage_push_file(self, file_content) -> str:
async def storage_push_file(self, file_content: bytes) -> Optional[str]:
"""
Push a file to the storage service.
"""
data = aiohttp.FormData()
data.add_field("file", file_content)
data.add_field("file", BytesIO(file_content))

url = "/api/v0/storage/add_file"
logger.debug(f"Posting file on {url}")
Expand Down Expand Up @@ -669,7 +670,7 @@ async def _storage_push_file_with_message(
content_type="application/json",
)
# Add the file
data.add_field("file", file_content)
data.add_field("file", BytesIO(file_content))

url = "/api/v0/storage/add_file"
logger.debug(f"Posting file on {url}")
Expand Down