C# implementation of FrostFS SDK
sdk
Find a file
Pavel Gross 85506a997e
Some checks failed
DCO / DCO (pull_request) Failing after 44s
[#10] Netmap metrics and options
2024-06-24 12:12:53 +03:00
.forgejo/workflows Add empty repo 2024-04-24 14:59:21 +03:00
src [#10] Netmap metrics and options 2024-06-24 12:12:53 +03:00
.gitignore [#10] Netmap metrics and options 2024-06-24 12:12:53 +03:00
FrostFS.SDK.sln [#10] Netmap metrics and options 2024-06-24 12:12:53 +03:00
LICENSE Initial commit 2024-04-24 09:46:03 +00:00
README.md [#10] Netmap metrics and options 2024-06-24 12:12:53 +03:00

frostfs-sdk-csharp

C# implementation of FrostFS SDK.

Prerequisites

Get the key for your wallet

  1. Get the address
cat <path_to_your_wallet> | jq .accounts[0].address | tr -d '"'
  1. 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);
}