Skip to content
TopperDEL edited this page Apr 16, 2020 · 19 revisions

Introduction

This wiki should help you get started with Storj/Tardigrade and the uplink.NET-library.

First steps

Create a new .Net-project (.Net, UWP and Xamarin.Android will work currently) and add the "uplink.NET"-Nuget to the project.

To use the library you need an account on a Storj/Tardigrade-satellite or a local storj-sim-environment. See tardigrade.io for further info. If you have access to a satellite, create a new project and API key.

Then you'll need to init uplink.NET like this. First, init a Scope using your API-Key, your satellite-address, your encryption secret and a temp-path to use:

Access.SetTempDirectory(System.IO.Path.GetTempPath());
_access = new Access("YOUR_SATELLITE_URL_WITH:PORT_HERE", "YOUR_API_KEY_HERE", "YOUR_PESONAL_ENCRYPTION_KEY");

If you're on Android, set the temp-directory like this:

Access.SetTempDirectory(CacheDir.AbsolutePath);

Then you'll be able to use the BucketService and the ObjectService like this:

var bucketService = new BucketService(_access);
ListBucketsOptions listOptions = new ListBucketsOptions();
var buckets = await bucketService.ListBucketsAsync(listOptions);

To add a new bucket, use the CreateBucket-Method:

var bucketInfo = await bucketService.CreateBucketAsync("mybucket");

Listing, uploading and downloading of objects (i.e. binary data) works through the ObjectService. The following code would open a bucket "testbucket" and list all objects within the bucket:

var bucketService = new BucketService(_access);
var bucket = await bucketService.GetBucketAsync("testbucket");

var objectService = new ObjectService(_access);
var objects = await objectService.ListObjectsAsync(bucket, new ListObjectsOptions());
foreach (var obj in objects.Items)
{
     //work with the objects
}

To download the object "test.jpg" from "testbucket" using the open bucket do the following:

var downloadOperation = objectService.DownloadObjectAsync(bucket, "test.jpg", new DownloadOptions(), false);
downloadOperation.DownloadOperationProgressChanged += //add event handler
await downloadOperation.StartDownloadAsync();

The same would be for an upload.

Clone this wiki locally