Thanks to visit codestin.com
Credit goes to github.com

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
27 changes: 18 additions & 9 deletions src/aleph_client/commands/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import aiohttp
import typer
from aiohttp import ClientResponseError
from aleph.sdk import AlephHttpClient, AuthenticatedAlephHttpClient
from aleph.sdk.account import _load_account
from aleph.sdk.conf import settings
Expand Down Expand Up @@ -88,15 +89,23 @@ async def upload(
logger.debug("Uploading file")
result: StoreMessage
status: MessageStatus
result, status = await client.create_store(
file_content=file_content,
storage_engine=storage_engine,
channel=channel,
guess_mime_type=True,
ref=ref,
)
logger.debug("Upload finished")
typer.echo(f"{result.model_dump_json(indent=4)}")
try:
result, status = await client.create_store(
file_content=file_content,
storage_engine=storage_engine,
channel=channel,
guess_mime_type=True,
ref=ref,
)
logger.debug("Upload finished")
typer.echo(f"{result.model_dump_json(indent=4)}")
except ClientResponseError as e:
typer.echo(f"{e}")

if e.status == 413:
typer.echo("File is too large to be uploaded. Please use aleph file pin")
else:
typer.echo(f"Error uploading file\nstatus: {e.status}\nmessage: {e.message}")


@app.command()
Expand Down
Loading