Skip to content

Commit 5dc04dd

Browse files
committed
update README.md
1 parent e2f4d8f commit 5dc04dd

2 files changed

Lines changed: 97 additions & 2 deletions

File tree

README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Pinata.Client for .NET/C# Library
55

66
Project Description
77
-------------------
8-
A .NET implementation for the [Pinata API](https://pinata.cloud/documentation).
8+
A .NET implementation for [Pinata Cloud](https://pinata.cloud/documentation).
99

1010
[1]:https://docs.microsoft.com/en-us/mem/configmgr/core/plan-design/security/enable-tls-1-2-client
1111
[2]:https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls
@@ -30,11 +30,66 @@ Install-Package Pinata.Client
3030
Getting Started
3131
------
3232

33+
```csharp
34+
var config = new Config
35+
{
36+
ApiKey = "2981f1eb1813daf...",
37+
ApiSecret = "42281fa28de32fe3c..."
38+
};
39+
40+
var client = new PinataClient(config);
41+
42+
var html = @"
43+
<html>
44+
<head>
45+
<title>Hello IPFS!</title>
46+
</head>
47+
<body>
48+
<h1>Hello World</h1>
49+
</body>
50+
</html>
51+
";
52+
53+
var metadata = new PinataMetadata // optional
54+
{
55+
KeyValues =
56+
{
57+
{"Author", "Brian Chavez"}
58+
}
59+
};
60+
61+
var options = new PinataOptions(); // optional
62+
63+
options.CustomPinPolicy.AddOrUpdateRegion("NYC1", desiredReplicationCount: 1);
64+
65+
var response = await this.client.Pinning.PinFileToIpfsAsync(content =>
66+
{
67+
var file = new StringContent(html, Encoding.UTF8, MediaTypeNames.Text.Html);
68+
69+
content.AddPinataFile(file, "index.html");
70+
},
71+
metadata,
72+
options);
73+
74+
if( response.IsSuccess )
75+
{
76+
//File uploaded to Pinata Cloud and can be accessed on IPFS!
77+
var hash = response.IpfsHash; // QmR9HwzakHVr67HFzzgJHoRjwzTTt4wtD6KU4NFe2ArYuj
78+
}
79+
```
80+
81+
Now your file can be accessed over [IPFS](https://ipfs.io/) and accessed via [Cloudflare's IPFS gateway](https://cloudflare-ipfs.com/)!
82+
83+
```
84+
https://cloudflare-ipfs.com/ipfs/QmR9HwzakHVr67HFzzgJHoRjwzTTt4wtD6KU4NFe2ArYuj
85+
```
86+
87+
Find more examples [here](https://github.com/bchavez/Pinata.Client/blob/master/Source/Pinata.Client.Tests/IntegrationTests/IntegrationTest.cs).
3388

3489
-------
3590

3691

37-
Easy peasy! **Happy file sharing!** :tada:
92+
Magic! Easy peasy! **Happy file sharing!** :tada:
3893

3994

4095
Reference

Source/Pinata.Client.Tests/IntegrationTests/IntegrationTest.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,46 @@ public async Task pinning_PinFileToIpfs_with_StringContent()
132132
});
133133
}
134134

135+
[Test]
136+
public async Task pinning_PinFileToIpfs_with_StringContent_with_options()
137+
{
138+
var html = @"
139+
<html>
140+
<head>
141+
<title>Hello IPFS!</title>
142+
</head>
143+
<body>
144+
<h1>Hello World</h1>
145+
</body>
146+
</html>
147+
";
148+
var metadata = new PinataMetadata // optional
149+
{
150+
KeyValues =
151+
{
152+
{"Author", "Brian Chavez"}
153+
}
154+
};
155+
156+
var options = new PinataOptions(); // optional
157+
options.CustomPinPolicy.AddOrUpdateRegion("NYC1", desiredReplicationCount: 1);
158+
159+
var response = await this.client.Pinning.PinFileToIpfsAsync(content =>
160+
{
161+
var file = new StringContent(html, Encoding.UTF8, MediaTypeNames.Text.Html);
162+
163+
content.AddPinataFile(file, "index.html");
164+
},
165+
metadata,
166+
options);
167+
168+
if( response.IsSuccess )
169+
{
170+
//File uploaded to Pinata Cloud, now on IPFS!
171+
var hash = response.IpfsHash;
172+
}
173+
}
174+
135175
[Test]
136176
public async Task pinning_HashMetadata_set()
137177
{

0 commit comments

Comments
 (0)