Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: aiohttp issues a DeprecationWarning #129

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Changes from 1 commit
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
9 changes: 5 additions & 4 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 @@ -135,7 +136,7 @@ async def storage_push_file(self, file_content) -> str:
Push a file to the storage service.
"""
data = aiohttp.FormData()
data.add_field("file", file_content)
data.add_field("file", BytesIO(file_content))
hoh marked this conversation as resolved.
Show resolved Hide resolved

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
Loading