.NET SDK QuickStart
This document assumes that you have a working VisualStudio development environment.

Minimum Requirements

  • .NET 4.5.2, .NetStandard 2.0 or higher
  • Visual Studio 2017

Install from NuGet

To install MinIO .NET package, run the following command in Nuget Package Manager Console.
1
PM> Install-Package Minio
Copied!

OSS Client Example

To connect to an OSS Service Instance, you will need to specify the following parameters.
Parameter
Description
endpoint
URL to object storage service. (eg. storage-4175974314028753.cloud.bigconnect.io)
accessKey
Access key is the user ID that uniquely identifies your account.
secretKey
Secret key is the password to your account.
secure
Enable/Disable HTTPS support. Must be set to True.
Example:
1
using Minio;
2
3
// Initialize the client with access credentials.
4
private static MinioClient minio = new MinioClient("storage-4175974314028753.cloud.bigconnect.io",
5
"Q3AM3UQ867SPQQA43P2F",
6
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
7
).WithSSL();
8
9
// Create an async task for listing buckets.
10
var getListBucketsTask = minio.ListBucketsAsync();
11
12
// Iterate over the list of buckets.
13
foreach (Bucket bucket in getListBucketsTask.Result.Buckets)
14
{
15
Console.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime);
16
}
17
Copied!

Complete File Uploader Example

This example program connects to an object storage server, creates a bucket and uploads a file to the bucket. To run the following example, click on [Link] and start the project
1
using System;
2
using Minio;
3
using Minio.Exceptions;
4
using Minio.DataModel;
5
using System.Threading.Tasks;
6
7
namespace FileUploader
8
{
9
class FileUpload
10
{
11
static void Main(string[] args)
12
{
13
var endpoint = "storage-4175974314028753.cloud.bigconnect.io";
14
var accessKey = "Q3AM3UQ867SPQQA43P2F";
15
var secretKey = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
16
try
17
{
18
var minio = new MinioClient(endpoint, accessKey, secretKey).WithSSL();
19
FileUpload.Run(minio).Wait();
20
}
21
catch (Exception ex)
22
{
23
Console.WriteLine(ex.Message);
24
}
25
Console.ReadLine();
26
}
27
28
// File uploader task.
29
private async static Task Run(MinioClient minio)
30
{
31
var bucketName = "mymusic";
32
var location = "default";
33
var objectName = "golden-oldies.zip";
34
var filePath = "C:\\Users\\username\\Downloads\\golden_oldies.mp3";
35
var contentType = "application/zip";
36
37
try
38
{
39
// Make a bucket on the server, if not already present.
40
bool found = await minio.BucketExistsAsync(bucketName);
41
if (!found)
42
{
43
await minio.MakeBucketAsync(bucketName, location);
44
}
45
// Upload a file to bucket.
46
await minio.PutObjectAsync(bucketName, objectName, filePath, contentType);
47
Console.WriteLine("Successfully uploaded " + objectName );
48
}
49
catch (MinioException e)
50
{
51
Console.WriteLine("File Upload Error: {0}", e.Message);
52
}
53
}
54
}
55
}
Copied!

Running Examples

On Windows
  • Clone this repository and open the Minio.Sln in Visual Studio 2017.
  • Enter your credentials and bucket name, object name etc.in Minio.Examples/Program.cs Uncomment the example test cases such as below in Program.cs to run an example.
1
//Cases.MakeBucket.Run(minioClient, bucketName).Wait();
Copied!
  • Run the Minio.Client.Examples project from Visual Studio #### On Linux (Ubuntu 16.04)
Setting up Mono and .NETCore on Linux
NOTE: minio-dotnet requires mono 5.0.1 stable release and .NET Core 2.0 SDK to build on Linux.
1
$ ./mono_install.sh
Copied!
Running Minio.Examples
  • Clone this project.
1
$ git clone https://github.com/minio/minio-dotnet && cd minio-dotnet
Copied!
  • Enter your credentials and bucket name, object name etc. in Minio.Examples/Program.cs Uncomment the example test cases such as below in Program.cs to run an example.
1
//Cases.MakeBucket.Run(minioClient, bucketName).Wait();
Copied!
1
$ cd Minio.Examples
2
$ dotnet build -c Release
3
$ dotnet run
Copied!
Have a look at the .NET SDK Reference for more information.
Last modified 1yr ago