A .NET implementation for Pinata Cloud.
- .NET Standard 2.0 or later
- .NET Framework 4.5 or later
- TLS 1.2 or later
Nuget Package Pinata.Client
Install-Package Pinata.Client
var config = new Config
{
ApiKey = "2981f1eb1813daf...",
ApiSecret = "42281fa28de32fe3c..."
};
var client = new PinataClient(config);
var html = @"
<html>
<head>
<title>Hello IPFS!</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
";
var metadata = new PinataMetadata // optional
{
KeyValues =
{
{"Author", "Brian Chavez"}
}
};
var options = new PinataOptions(); // optional
options.CustomPinPolicy.AddOrUpdateRegion("NYC1", desiredReplicationCount: 1);
var response = await this.client.Pinning.PinFileToIpfsAsync(content =>
{
var file = new StringContent(html, Encoding.UTF8, MediaTypeNames.Text.Html);
content.AddPinataFile(file, "index.html");
},
metadata,
options);
if( response.IsSuccess )
{
//File uploaded to Pinata Cloud and can be accessed on IPFS!
var hash = response.IpfsHash; // QmR9HwzakHVr67HFzzgJHoRjwzTTt4wtD6KU4NFe2ArYuj
}
Now your file can be accessed over IPFS and accessed via Cloudflare's IPFS gateway!
https://cloudflare-ipfs.com/ipfs/QmR9HwzakHVr67HFzzgJHoRjwzTTt4wtD6KU4NFe2ArYuj
Find more examples here.
Magic! Easy peasy! Happy file sharing! 🎉
- Download the source code.
- Run
build.cmd
.
Upon successful build, the results will be in the \__compile
directory. If you want to build NuGet packages, run build.cmd pack
and the NuGet packages will be in __package
.
Created by Brian Chavez.
A big thanks to GitHub and all contributors!
Note: This application/third-party library is not directly supported by Pinata Technologies, Inc. Pinata Technologies, Inc. makes no claims about this application/third-party library. This application/third-party library is not endorsed or certified by Pinata Technologies, Inc.