Backup and normalize creative assets: a workflow (ProcedureExecution) that ingests from Dropbox, creates an artifact record stored as an R2 object (Information Bearing Entity), deduplicates by content hash (SHA-256), and establishes a product-artifact link to the target product.
Goal: Reliable asset redundancy and a canonical bearer URL per product.
Step: Deduplicate — Worker checks macrodata_artifact.content_hash_identifier (kind: design_asset) for existing match — if found, reuses existing record
Step: Store — Worker uploads to R2 via binding API (env.R2_BUCKET.put()) — creates the stored file (R2 object)
Step: Record — Worker upserts:
macrodata_artifact(content_hash_identifier, bearer_entity_key, bearer_entity_url, file_size, content_type, dropbox_url) (kind: design_asset) — the design asset record
link_product_macrodata_artifact(product_id, macrodata_artifact_id) — product-artifact link
Step: Metafield — Worker updates Shopify metafield custom.production_asset_url with bearer_entity_url
sequenceDiagram
participant User as Staff
participant API as Dashboard API
participant Q as CF Queue
participant Ingest as Ingest Worker
participant Dropbox as Dropbox
participant R2 as R2
participant DB as PlanetScale
participant Shopify as Shopify API
User->>API: POST /api/assets/ingest
API->>Q: enqueue ICE_INGEST
API-->>User: 202 Accepted + job_id
Q->>Ingest: deliver
Ingest->>Dropbox: fetch asset stream
Ingest->>Ingest: compute content hash (SHA-256)
Ingest->>R2: put(R2 object)
Ingest->>DB: upsert macrodata_artifact + link_product_macrodata_artifact
Ingest->>Shopify: update metafield (bearer_entity_url)