Add IPFS CID support for asset lookup

- Upload endpoint returns both CID and content_hash
- Cache manager handles both SHA3-256 hashes and IPFS CIDs
- get_by_cid() fetches from IPFS if not cached locally
- Execute tasks support :cid in addition to :hash

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 07:36:18 +00:00
parent c7c7c90909
commit 494a2a8650
4 changed files with 51 additions and 14 deletions

View File

@@ -209,9 +209,9 @@ async def upload_content(
ctx: UserContext = Depends(require_auth),
cache_service: CacheService = Depends(get_cache_service),
):
"""Upload content to cache."""
"""Upload content to cache and IPFS."""
content = await file.read()
content_hash, error = await cache_service.upload_content(
content_hash, ipfs_cid, error = await cache_service.upload_content(
content=content,
filename=file.filename,
actor_id=ctx.actor_id,
@@ -221,7 +221,8 @@ async def upload_content(
raise HTTPException(400, error)
return {
"content_hash": content_hash,
"cid": ipfs_cid,
"content_hash": content_hash, # Legacy, for backwards compatibility
"filename": file.filename,
"size": len(content),
"uploaded": True,