Forge.ArtifactStorage behaviour (Forge v0.1.1)
View SourceBehaviour for artifact storage backends.
Artifacts are large binary or text payloads that don't belong in Postgres, such as raw narratives, LLM responses, embeddings, or serialized models.
Callbacks
put_blob/4- Store a blob and return its URIget_blob/2- Retrieve a blob by URIsigned_url/2- Generate time-limited signed URL for blob accessdelete_blob/1- Remove a blob from storage
Content Addressing
All adapters should use content-addressable storage (SHA256 hash) for immutability and deduplication.
Examples
# Store a blob
{:ok, uri} = adapter.put_blob(sample_id, "raw_narrative", content, bucket: "forge-artifacts")
# Retrieve it
{:ok, content} = adapter.get_blob(uri)
# Get signed URL for frontend access
{:ok, url} = adapter.signed_url(uri, expires_in: 3600)
Summary
Callbacks
Delete a blob from storage.
Retrieve a blob by its storage URI.
Store a blob and return its storage URI.
Generate a time-limited signed URL for blob access.
Callbacks
Delete a blob from storage.
Parameters
uri- The storage URI to delete
Returns
:ok- Success{:error, reason}- Failure
Retrieve a blob by its storage URI.
Parameters
uri- The storage URI returned byput_blob/4opts- Storage-specific options
Returns
{:ok, binary}- Success with blob content{:error, reason}- Failure (e.g., not found)
@callback put_blob( sample_id :: String.t(), key :: String.t(), data :: binary(), opts :: keyword() ) :: {:ok, uri :: String.t()} | {:error, term()}
Store a blob and return its storage URI.
Parameters
sample_id- The sample ID this artifact belongs tokey- The artifact key (e.g., "raw_narrative", "embedding")data- The binary content to storeopts- Storage-specific options
Returns
{:ok, uri}- Success with storage URI{:error, reason}- Failure
Generate a time-limited signed URL for blob access.
Useful for providing temporary access to artifacts without exposing storage credentials.
Parameters
uri- The storage URIopts- Options including:expires_in(seconds)
Returns
{:ok, url}- Signed URL string{:error, reason}- Failure