Show CID for asset uploads
- Display IPFS CID after upload - Show recipe syntax with :cid Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -519,7 +519,7 @@ def import_file(filepath):
|
|||||||
@cli.command()
|
@cli.command()
|
||||||
@click.argument("filepath", type=click.Path(exists=True))
|
@click.argument("filepath", type=click.Path(exists=True))
|
||||||
def upload(filepath):
|
def upload(filepath):
|
||||||
"""Upload a file to cache (works with remote servers). Requires login."""
|
"""Upload a file to cache and IPFS. Requires login."""
|
||||||
# Check auth
|
# Check auth
|
||||||
token_data = load_token()
|
token_data = load_token()
|
||||||
if not token_data.get("access_token"):
|
if not token_data.get("access_token"):
|
||||||
@@ -536,8 +536,11 @@ def upload(filepath):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
result = resp.json()
|
result = resp.json()
|
||||||
click.echo(f"Uploaded: {result['content_hash']}")
|
click.echo(f"CID: {result['cid']}")
|
||||||
click.echo(f"Size: {result['size']} bytes")
|
click.echo(f"Size: {result['size']} bytes")
|
||||||
|
click.echo()
|
||||||
|
click.echo("Use in recipes:")
|
||||||
|
click.echo(f' (asset my-asset :cid "{result["cid"]}")')
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
click.echo(f"Upload failed: {e}", err=True)
|
click.echo(f"Upload failed: {e}", err=True)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user