KuboPinning¶
Namespace Nfty.Core.Publish.Ipfs in assembly Nfty.Core.
A local IPFS node — IPFS Desktop or the Kubo daemon — reached over its HTTP RPC.
Remarks¶
Status is POST /api/v0/version (and /api/v0/id for the peer id). The RPC refuses GET, so every call is a POST; a node that answers anything at all is running.
Add is POST /api/v0/add?wrap-with-directory=true&cid-version=1&pin=true with one multipart part per file, each named by its path inside the folder. The node adds the files, wraps them in one directory and pins it; the LAST line of its newline-delimited answer — the one with an empty Name — is that wrapper, so its Hash is the folder's contents and ipfs://CID/1.png resolves. Nested folders are sent as explicit directory parts, which is what Kubo's multipart reader expects.
Nothing here is a secret: the RPC on 127.0.0.1 takes no key. Anyone who can reach that port can already do anything to the node.
Constructors¶
KuboPinning(HttpClient, string)¶
Creates the client.
Parameters
http(HttpClient) - The client to speak through. Its timeout should be infinite: an upload of a large collection takes as long as it takes, and the token stops it.api(string) - The RPC address, e.g.KuboPinning.DefaultApi.
Exceptions
ArgumentException- The address is not an absolute http(s) URL.
Fields¶
DefaultApi¶
Where IPFS Desktop and ipfs daemon listen unless told otherwise.
StatusTimeout¶
How long a status check waits before calling the node unreachable.
Properties¶
Api¶
The RPC address this client talks to.
Provider¶
Which service this is, as a person reads it.
Methods¶
AddFolderAsync(string, string, IProgress<PinProgress>?, CancellationToken)¶
public Task<string> AddFolderAsync(string folder, string label, IProgress<PinProgress>? progress = null, CancellationToken cancellationToken = default);
Adds and pins every file under folder, returning the CID of a directory whose entries are those files.
Parameters
folder(string) - The folder whose contents to add.label(string) - A name for the pin where the service keeps one (Pinata's dashboard).progress(IProgress<PinProgress>?) - Bytes sent so far.cancellationToken(CancellationToken) - Stops the upload. What the service already received may stay on it.
Returns. The root CID.
Exceptions
ArgumentException- The folder is missing or holds no file.PinningException- The service refused, failed or answered without a CID.
ApiProblem(string?)¶
Why a typed RPC address cannot be used, or null when it can.
Parameters
api(string?) - The address as typed.
Returns. The sentence, or null.
StatusAsync(CancellationToken)¶
Asks whether the service can be reached and accepts the credentials. Never throws for an unreachable service: that is an answer, reported in the result.
Parameters
cancellationToken(CancellationToken) - Stops the check.
Returns. What was found.