Show / Hide Table of Contents

Interface IObjectApi

Manages the IPFS Directed Acrylic Graph.

Namespace: Ipfs.CoreApi
Assembly: Ipfs.Core.dll
Syntax
public interface IObjectApi
Remarks
note

This is being obsoleted by IDagApi.

Methods

| Improve this Doc View Source

DataAsync(Cid, CancellationToken)

Get the data of a MerkleDAG node.

Declaration
Task<Stream> DataAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
Cid id

The Cid of the node.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<Stream>

A task that represents the asynchronous operation. The task's value is a stream of data.

Remarks

The caller must dispose the returned Stream.

| Improve this Doc View Source

GetAsync(Cid, CancellationToken)

Fetch a MerkleDAG node.

Declaration
Task<DagNode> GetAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
Cid id

The Cid to the node.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<DagNode>

A task that represents the asynchronous operation. The task's value is a DagNode.

| Improve this Doc View Source

LinksAsync(Cid, CancellationToken)

Get the links of a MerkleDAG node.

Declaration
Task<IEnumerable<IMerkleLink>> LinksAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
Cid id

The unique id of the node.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<IEnumerable<IMerkleLink>>

A task that represents the asynchronous operation. The task's value is a sequence of links to the immediate children.

Remarks

LinksAsync returns the immediate child links of the id. To get all the children, this code can be used.

async Task<List<IMerkleLink>> AllLinksAsync(Cid cid)
{
  var i = 0;
  var allLinks = new List<IMerkleLink>();
  while (cid != null)
  {
     var links = await ipfs.Object.LinksAsync(cid);
     allLinks.AddRange(links);
     cid = (i < allLinks.Count) ? allLinks[i++].Id : null;
  }
  return allLinks;
}
| Improve this Doc View Source

NewAsync(String, CancellationToken)

Create a new MerkleDAG node, using a specific layout.

Declaration
Task<DagNode> NewAsync(string template = null, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String template

null or "unixfs-dir".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<DagNode>

A task that represents the asynchronous operation. The task's value is a DagNode to the new directory.

Remarks

Caveat: So far, only UnixFS object layouts are supported.

| Improve this Doc View Source

NewDirectoryAsync(CancellationToken)

Creates a new file directory in IPFS.

Declaration
Task<DagNode> NewDirectoryAsync(CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<DagNode>

A task that represents the asynchronous operation. The task's value is a DagNode to the new directory.

Remarks

Equivalent to NewAsync("unixfs-dir").

| Improve this Doc View Source

PutAsync(DagNode, CancellationToken)

Store a MerkleDAG node.

Declaration
Task<DagNode> PutAsync(DagNode node, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
DagNode node

A merkle dag

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<DagNode>

A task that represents the asynchronous operation. The task's value is a DagNode.

| Improve this Doc View Source

PutAsync(Byte[], IEnumerable<IMerkleLink>, CancellationToken)

Store a MerkleDAG node.

Declaration
Task<DagNode> PutAsync(byte[] data, IEnumerable<IMerkleLink> links = null, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
Byte[] data

The opaque data, can be null.

IEnumerable<IMerkleLink> links

The links to other nodes.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<DagNode>

A task that represents the asynchronous operation. The task's value is a DagNode.

| Improve this Doc View Source

StatAsync(Cid, CancellationToken)

Information on a MerkleDag node.

Declaration
Task<ObjectStat> StatAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
Cid id

The Cid of the node.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<ObjectStat>

A task that represents the asynchronous operation. The task's value contains the ObjectStat.

See Also

IDagApi
DagNode
Object API spec
  • Improve this Doc
  • View Source
Back to top Generated by DocFX