-
Notifications
You must be signed in to change notification settings - Fork 4
Home
This wiki should help you get started with Storj DCS (Decentralized Cloud Storage) and the uplink.NET-library.
Storj DCS is described here. Basically it is a decentralised, secure, fast, S3-compatible cloud-base object store. That means you can upload "objects" (binary data of any form) to the cloud, list it and of course download it again. There are many ways to connect to the cloud and the objects you've placed there. uplink.Net is a direct way - meaning: there is no intermediate like a gateway between your application and the cloud storage. Your application written in C#/.Net communicates directly with the decentralised so called nodes and the satellites managing the metadata. All traffic leaving your app is encrypted with a key you choose and cannot be read by anyone else (except you give permission, see "access sharing").
The uplink.Net-library can be included in any .Net-application running on all major platforms and architectures. It works on Windows, Linux, MacOs, iOs, Android and even the ARM64-based Hololens 2. On Windows it supports x86 and x64.
It is already heavily used in the backup-application Duplicati, that also supports Windows, Linux and MacOs. Furthermore it is used to be the main backend for some Open- and Closed-Source cross-platform Uno-applications and will soon make it's debut on Hololens using the awesome StereoKitframework.
Want to know how to benefit from uplink.Net on your own? Let's digg into!
Create a new project (supported are NetFramework, NetCore, UWP, Linux, Xamarin.MacOS, Xamarin.Android, Xamarin.iOS and the Uno-Platform) 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");
You might also get an access by providing an access grant:
_access = new Access("YOUR_SERIALISED_ACCESS_GRANT");
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.