Minio .Net Library is not yet ready for general purpose use
This quickstart guide will show you how to install the Minio client SDK, connect to Minio, and provide a walkthrough for a simple file uploader. For a complete list of APIs and examples, please take a look at the Go Client API Reference.
This document assumes that you have a working VisualStudio development environment
Minio client requires the following four parameters specified to connect to an Amazon S3 compatible object storage.
Parameter | Description |
---|---|
endpoint | URL to object storage service. |
accessKeyID | Access key is the user ID that uniquely identifies your account. |
secretAccessKey | Secret key is the password to your account. |
secure | Chain WithSSL() method to client object to enable secure (HTTPS) access. |
using Minio;
private static MinioClient client = var minio = new MinioRestClient("play.minio.io:9000",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
).WithSSL();
var getListBucketsTask = minio.Buckets.ListBucketsAsync();
Task.WaitAll(getListBucketsTask); // block while the task completes
var list = getListBucketsTask.Result;
foreach (Bucket bucket in list.Buckets
{
Console.Out.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime);
}
This example program connects to an object storage server, creates a bucket and uploads a file to the bucket.
using System;
using Minio;
using Minio.Exceptions;
using Minio.DataModel;
using System.Threading.Tasks;
namespace FileUploader
{
class FileUpload
{
static void Main(string[] args)
{
var endpoint = "play.minio.io:9000";
var accessKey = "Q3AM3UQ867SPQQA43P2F";
var secretKey = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
try
{
var minio = new MinioRestClient(endpoint, accessKey, secretKey).WithSSL();
FileUpload.Run(minio).Wait();
}
catch (Exception ex)
{
Console.Out.WriteLine(ex.Message);
}
Console.ReadLine();
}
//Check if a bucket exists
private async static Task Run(MinioRestClient minio)
{
// Make a new bucket called mymusic.
var bucketName = "mymusic";
var location = "us-east-1";
// Upload the zip file
var objectName = "golden-oldies.zip";
var filePath = "/tmp/golden-oldies.zip";
var contentType = "application/zip";
try
{
bool success = await minio.Buckets.MakeBucketAsync(bucketName, location);
if (!success) {
bool found = await minio.Buckets.BucketExistsAsync(bucketName);
Console.Out.WriteLine("bucket-name was " + ((found == true) ? "found" : "not found"));
}
else {
await minio.Objects.PutObjectAsync(bucketName, objectName, filePath, contentType);
Console.Out.WriteLine("Successfully uploaded " + objectName);
}
}
catch (Exception e)
{
Console.WriteLine("[Bucket] Exception: {0}", e);
}
}
}
}
Click on FileUploader project and Start
- MakeBucket.cs
- ListBuckets.cs
- BucketExists.cs
- RemoveBucket.cs
- ListIncompleteUploads.cs
- Listobjects.cs
- [GetPolicy.cs] (./Minio.Examples/Cases/GetPolicy.cs)
- [SetPolicy.cs] (./Minio.Examples/Cases/SetPolicy.cs)
- [FGetObject.cs] (./Minio.Examples/Cases/FGetObject.cs)
- [FPutObject.cs] (./Minio.Examples/Cases/FPutObject.cs)
- [GetObject.cs] (./Minio.Examples/Cases/GetObject.cs)
- [PutObject.cs] (./Minio.Examples/Cases/PutObject.cs)
- StatObject.cs
- RemoveObject.cs
- RemoveIncompleteUpload.cs
- [CopyObject.cs] (./Minio.Examples/Cases/CopyObject.cs)
- [SetAppInfo] (./Minio.Examples/Program.cs)
•Build Minio solution
•Move into Minio.Examples directory and run the project. Uncomment cases that you want to run to play with it.