C# implementation of FrostFS SDK
|
||
---|---|---|
.forgejo/workflows | ||
src | ||
.gitignore | ||
FrostFS.SDK.sln | ||
LICENSE | ||
README.md |
frostfs-sdk-csharp
C# implementation of FrostFS SDK.
Prerequisites
Get the key for your wallet
- Get the address
cat <path_to_your_wallet> | jq .accounts[0].address | tr -d '"'
- Get the key
neo-go wallet export -w <path_to_your_wallet> -d <address_from_p1>
Example usage
Container
using FrostFS.SDK.ClientV2;
using FrostFS.SDK.ModelsV2;
using FrostFS.SDK.ModelsV2.Enums;
using FrostFS.SDK.ModelsV2.Netmap;
using Microsoft.Extensions.Options;
var options = Options.Create(new ClientSettings
{
Key = <your_key>,
Host = <your_host>
});
var fsClient = Client.GetInstance(options);
// Mertics
fsClient.GrpcInvoked += (sender, info) =>
{
Console.WriteLine($"Invoked: {info.MethodName}. Elapsed time: {info.ElapsedTimeMicroSec}");
};
var placementPolicy = new PlacementPolicy(true, new Replica(1));
var containerId = await fsClient.CreateContainerAsync(new Container(BasicAcl.PublicRW, placementPolicy));
// Put object
var fileStream = File.OpenRead("cat.jpg");
var header = new ObjectHeader(
containerId: containerId,
type: ObjectType.Regular,
new ObjectAttribute("Filename", "cat.jpg")
);
var param = new PutObjectParameters
{
Header = header,
Payload = fileStream
};
var oId = await fsClient.PutObjectAsync(param);
// Search regular objects
await foreach (var objId in fsClient.SearchObjectsAsync(containerId, [ObjectFilter.RootFilter()]))
{
// Get object header
var info = await fsClient.GetObjectHeadAsync(containerId, objId);
// Get object
var obj = await fsClient.GetObjectAsync(containerId, oId);
}