PinataNET 1.0.2
dotnet add package PinataNET --version 1.0.2
NuGet\Install-Package PinataNET -Version 1.0.2
<PackageReference Include="PinataNET" Version="1.0.2" />
<PackageVersion Include="PinataNET" Version="1.0.2" />
<PackageReference Include="PinataNET" />
paket add PinataNET --version 1.0.2
#r "nuget: PinataNET, 1.0.2"
#:package PinataNET@1.0.2
#addin nuget:?package=PinataNET&version=1.0.2
#tool nuget:?package=PinataNET&version=1.0.2
PinataNET Documentation
Overview
PinataClient is a class for interacting with the Pinata API, allowing you to upload, pin, retrieve, update, and delete files on IPFS (InterPlanetary File System). The client requires a JWT (JSON Web Token) for authorization.
Installation
To use the PinataClient, ensure you have the following NuGet packages installed:
- Newtonsoft.Json
- HeyRed.Mime
Usage
Creating an Instance
To create an instance of PinataClient, you need to provide a JWT:
var pinataClient = new PinataClient("your_jwt_here");
Methods
PinFileToIPFSAsync
public async Task<PinFileResponse> PinFileToIPFSAsync(string filePath)
Pins a file to IPFS.
Parameters
filePath(string): The path of the file to be pinned.
Returns
PinFileResponse: A response containing the details of the pinned file.
Exceptions
- Throws
JsonExceptionif the file pinning fails.
Example
var pinFileResponse = await pinataClient.PinFileToIPFSAsync("path/to/your/file.txt");
UploadFileAsync
public async Task<FileResponse> UploadFileAsync(Stream fileStream, string fileName, string groupId = "")
Uploads a file to Pinata.
Parameters
fileStream(Stream): The stream of the file to be uploaded.fileName(string): The name of the file (including extension).groupId(string, optional): An optional group ID for the file.
Returns
FileResponse: A response containing the upload details.
Exceptions
- Throws
JsonExceptionif the upload fails.
Example
using (var fileStream = File.OpenRead("path/to/your/file.txt"))
{
var fileResponse = await pinataClient.UploadFileAsync(fileStream, "file.txt");
}
GetFilesListAsync
public async Task<GetFilesListResponse> GetFilesListAsync()
Retrieves a list of files from Pinata.
Returns
GetFilesListResponse: A response containing a list of files.
Exceptions
- Throws
Exceptionif the retrieval fails.
Example
var filesListResponse = await pinataClient.GetFilesListAsync();
GetFileById
public async Task<FileResponse> GetFileById(string id)
Gets a file by its ID.
Parameters
id(string): The ID of the file to retrieve.
Returns
FileResponse: A response containing the file details.
Exceptions
- Throws
Exceptionif the retrieval fails.
Example
var fileResponse = await pinataClient.GetFileById("your_file_id");
UpdateFileNameAsync
public async Task<FileResponse> UpdateFileNameAsync(string id, string newName)
Updates the name of a specified file.
Parameters
id(string): The ID of the file to update.newName(string): The new name for the file.
Returns
FileResponse: A response containing the updated file details.
Exceptions
- Throws
Exceptionif the update fails.
Example
var updatedFileResponse = await pinataClient.UpdateFileNameAsync("your_file_id", "new_file_name.txt");
DeleteFileAsync
public async Task<FileResponse> DeleteFileAsync(string id)
Deletes a specified file.
Parameters
id(string): The ID of the file to delete.
Returns
FileResponse: A response confirming the deletion of the file.
Exceptions
- Throws
Exceptionif the deletion fails.
Example
var deleteFileResponse = await pinataClient.DeleteFileAsync("your_file_id");
Error Handling
The PinataClient methods throw exceptions on failure, allowing you to handle errors gracefully in your application. Ensure that you wrap calls in try-catch blocks as needed.
try
{
var fileResponse = await pinataClient.UploadFileAsync(fileStream, "file.txt");
}
catch (JsonException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
catch (Exception ex)
{
Console.WriteLine($"An unexpected error occurred: {ex.Message}");
}
Conclusion
The PinataClient class provides a simple interface for interacting with the Pinata API, enabling file management on IPFS. Use the methods provided to easily pin, upload, retrieve, update, and delete files.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- MimeTypesMap (>= 1.0.8)
- Newtonsoft.Json (>= 13.0.3)
- System.Net.Http (>= 4.3.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PinataNET:
| Package | Downloads |
|---|---|
|
NextGenSoftware.OASIS.API.ONODE.Core
This sit's at a higher level of abstraction over OASIS API Core, and acts as the main Core (Business Logic Layer) to the OASIS API, whereas OASIS API Core is the core architecture and hosts the central managers such as ProviderManager, AvatarManager, HolonManager, etc, This package contains more higher level Managers (such as OLANDManager, MissionManager, ParksManager, MapManager, QuestManager, SEEDSManager, etc) and use cases built on top of OASIS API Core. This module also uses the OASISBootLoader to manage loading and using the OASISDNA/config for the ONODEONODE. OASIS API Core does not use the OASISBootLoader because it is at a lower level in the stack and so interface implementations (OASIS Providers) need to be manually injected into each Manager's constructor (DI) whereas this module and the OASISBootLoader manages all of this for you via the OASISDNA.json config file. Both OASIS.API.Native.Integrated.EndPoint & the REST API both use this module/package and provide a wrapper around it and are the recommeneded ways to use the OASIS API. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|