File tree 1 file changed +18
-9
lines changed
src/aleph_client/commands
1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import aiohttp
10
10
import typer
11
+ from aiohttp import ClientResponseError
11
12
from aleph .sdk import AlephHttpClient , AuthenticatedAlephHttpClient
12
13
from aleph .sdk .account import _load_account
13
14
from aleph .sdk .conf import settings
@@ -88,15 +89,23 @@ async def upload(
88
89
logger .debug ("Uploading file" )
89
90
result : StoreMessage
90
91
status : MessageStatus
91
- result , status = await client .create_store (
92
- file_content = file_content ,
93
- storage_engine = storage_engine ,
94
- channel = channel ,
95
- guess_mime_type = True ,
96
- ref = ref ,
97
- )
98
- logger .debug ("Upload finished" )
99
- typer .echo (f"{ result .model_dump_json (indent = 4 )} " )
92
+ try :
93
+ result , status = await client .create_store (
94
+ file_content = file_content ,
95
+ storage_engine = storage_engine ,
96
+ channel = channel ,
97
+ guess_mime_type = True ,
98
+ ref = ref ,
99
+ )
100
+ logger .debug ("Upload finished" )
101
+ typer .echo (f"{ result .model_dump_json (indent = 4 )} " )
102
+ except ClientResponseError as e :
103
+ typer .echo (f"{ e } " )
104
+
105
+ if e .status == 413 :
106
+ typer .echo ("File is too large to be uploaded. Please use aleph file pin" )
107
+ else :
108
+ typer .echo (f"Error uploading file\n status: { e .status } \n message: { e .message } " )
100
109
101
110
102
111
@app .command ()
You can’t perform that action at this time.
0 commit comments