-
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 StereoKit-framework.
Want to know how to benefit from uplink.NET on your own? Let's digg into!
In a hurry? Let's get the basics set up quickly:
- Install the uplink.NET-Nuget into your project. It contains the C#-objects to interact with the library.
- Install the platform-specific nugets - those add the specific binaries to your application:
- on Windows install the uplink.NET.Win-nuget
- on Linux install the uplink.NET.Linux-nuget
- on MacOs install the uplink.NET.Mac-nuget
- on iOs install the uplink.NET.iOs-nuget
- on Android install the uplink.NET.Droid-nuget
- on Hololens 2 (ARM64) you need to wait a bit - it is currently in the works
- on Xamarin- and Uno-projects simply install the uplink.NET-nuget to the projects where you interact with the library and add the platform-specific nugets to the "head"-projects.
- Do some initialization:
- on iOs call the following method before your first interaction with the library:
uplink.NET.Models.Access.Init_iOs(Foundation.NSBundle.MainBundle.BundlePath);
- on all platforms (optionally): setup a temp-directory to use, e.g.:
uplink.NET.Models.Access.SetTempDirectory(System.IO.Path.GetTempPath());
- on iOs call the following method before your first interaction with the library:
Now you are ready to use uplink.NET!
If you know about Storj DCS and only need some code to quickstart, takes this:
//Get an access-object from your access-grant
var access = new Access("YOUR_ACCESS_GRANT");
//Get a bucket-service instance
var bucketService = new BucketService(access);
//Create a new bucket called "mybucket"
await bucketService.CreateBucketAsync("mybucket");
//List all available buckets
ListBucketsOptions listOptions = new ListBucketsOptions();
var buckets = await bucketService.ListBucketsAsync(listOptions);
foreach (var bucket in buckets.Items)
{
//work with the bucket
}
//Get the bucket "mybucket"
var bucket = await bucketService.GetBucketAsync("mybucket");
//Upload a simple text-file
byte[] bytesToUpload = Encoding.UTF8.GetBytes("Storj is awesome!");;
var uploadOperation = await _objectService.UploadObjectAsync(bucket, "awesome.txt", new UploadOptions(), bytesToUpload, false);
await uploadOperation.StartUploadAsync();
//List all available objects
var objectService = new ObjectService(access);
var objects = await objectService.ListObjectsAsync(bucket, new ListObjectsOptions());
foreach (var obj in objects.Items)
{
//work with the object
}
//Download one object
var downloadOperation = objectService.DownloadObjectAsync(bucket, "awesome.txt", new DownloadOptions(), false);
downloadOperation.DownloadOperationProgressChanged += //optional: add event handler
await downloadOperation.StartDownloadAsync();
var downloadedContent = Encoding.UTF8.GetString(downloadOperation.DownloadedBytes); //=> "Storj is awesome!"
doc is currently work in progress
To use the library you need an account on a Storj DCS-satellite. See docs.storj.io for further info. If you have access to a satellite, create a new access grant.
First, create an access-object using your access grant:
var access = new Access("YOUR_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.