Examples
Worked workflow patterns using the IPFS node
1. Upload a Generated Report and Pin It Durably
A workflow generates a PDF/CSV report and needs it durably available via IPFS.
- Upstream node produces the file bytes in its output.
- IPFS node:
resource=storage,operation=uploadAndPin,inputDataKey={{upstreamOutputKey}},fileName=report.pdf, plusclusterBaseUrlif you have a Cluster for replication. - Store the returned
cidfor later retrieval or for embedding in a notification/email.
Why
storage/uploadAndPin instead of content/add: one node
call handles both "store it" and "make sure it's pinned (not garbage-collected)" — and transparently
uses Cluster replication when configured, without the workflow needing two branches.
2. Build a Directory Tree in MFS, Then Publish It Under a Stable Name
Assemble several files into a directory structure and expose it under one IPNS name that survives future updates.
- IPFS node:
resource=files,operation=write,mfsPath=/site/index.html,inputDataKey=htmlBytes(repeat per file —parents/create/truncateall default totrue). - IPFS node:
resource=files,operation=stat,mfsPath=/site→ read the resultingcid. - IPFS node:
resource=name,operation=publish,targetPath=/ipfs/{{cid}},keyName=self(or a dedicated key from key/generate). - Downstream consumers fetch
/ipns/<peerID>— always the latest version, no link updates required.
3. Guard a Pin-Removal Step With a Verification Check
Before unpinning content, confirm nothing else depends on it being intact first.
- IPFS node:
resource=pin,operation=verify,verbose=false→ checkverifiedand inspectbadPins. - Condition node: only proceed if the target
cidis not present inbadPins. - IPFS node:
resource=pin,operation=remove,cid={{targetCid}}.
4. Reclaim Disk Space With a Confirmed Garbage Collection
- IPFS node:
resource=repo,operation=stat,sizeOnly=true→ readrepoSizeBytesto decide whether GC is worthwhile. - Condition node: only continue if size exceeds a threshold.
- IPFS node:
resource=repo,operation=garbageCollect,confirmDestructive=true.
Pin anything you want to keep first. Garbage collection deletes every block that isn't
pinned — run pin/add on anything important before this step.
5. Verify Downloaded Content Hasn't Been Corrupted or Tampered With
- IPFS node:
resource=storage,operation=verifyIntegrity,cid={{expectedCid}}. - Condition node:
matches == true. - If false, route to an alert branch instead of trusting the content downstream.
6. Register and Use a Remote Pinning Service
Offload durability to a third-party pinning provider instead of running your own Cluster.
- IPFS node:
resource=pin,operation=remoteServiceAdd,remoteServiceName=myProvider,remoteServiceEndpoint={{providerUrl}},remoteServiceApiKey={{secret}}(one-time setup). - IPFS node:
resource=pin,operation=remoteAdd,cid={{cid}},remoteServiceName=myProvider,background=truefor a fire-and-forget pin request. - Later, IPFS node:
resource=pin,operation=remoteList,remoteServiceName=myProvider,statusFilter=pinnedto confirm it landed.