Minio 5.0.0
MinIO Client SDK for .NET
MinIO Client SDK provides higher level APIs for MinIO and Amazon S3 compatible cloud storage services.For a complete list of APIs and examples, please take a look at the Dotnet Client API Reference.This document assumes that you have a working VisualStudio development environment.
Install from NuGet
To install MinIO .NET package, run the following command in Nuget Package Manager Console.
PM> Install-Package Minio
MinIO Client Example
To connect to an Amazon S3 compatible cloud storage service, you need the following information
Variable name | Description |
---|---|
endpoint | <Domain-name> or <ip:port> of your object storage |
accessKey | User ID that uniquely identifies your account |
secretKey | Password to your account |
secure | boolean value to enable/disable HTTPS support (default=true) |
The following examples uses a freely hosted public MinIO service "play.min.io" for development purposes.
using Minio;
var endpoint = "play.min.io";
var accessKey = "Q3AM3UQ867trueSPQQA43P2F";
var secretKey = "zuf+tfteSlswRu7BJ86wtrueekitnifILbZam1KYY3TG";
var secure = true;
// Initialize the client with access credentials.
private static MinioClient minio = new MinioClient()
.WithEndpoint(endpoint)
.WithCredentials(accessKey, secretKey)
.WithSSL(secure)
.Build();
// Create an async task for listing buckets.
var getListBucketsTask = await minio.ListBucketsAsync().ConfigureAwait(false);
// Iterate over the list of buckets.
foreach (var bucket in getListBucketsTask.Result.Buckets)
{
Console.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime);
}
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
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.min.io";
var accessKey = "Q3AM3UQ867SPQQA43P2F";
var secretKey = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
try
{
var minio = new MinioClient()
.WithEndpoint(endpoint)
.WithCredentials(accessKey, secretKey)
.WithSSL()
.Build();
FileUpload.Run(minio).Wait();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
// File uploader task.
private async static Task Run(MinioClient minio)
{
var bucketName = "mymusic";
var location = "us-east-1";
var objectName = "golden-oldies.zip";
var filePath = "C:\\Users\\username\\Downloads\\golden_oldies.mp3";
var contentType = "application/zip";
try
{
// Make a bucket on the server, if not already present.
var beArgs = new BucketExistsArgs()
.WithBucket(bucketName);
bool found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
if (!found)
{
var mbArgs = new MakeBucketArgs()
.WithBucket(bucketName);
await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false);
}
// Upload a file to bucket.
var putObjectArgs = new PutObjectArgs()
.WithBucket(bucketName)
.WithObject(objectName)
.WithFileName(filePath)
.WithContentType(contentType);
await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false);
Console.WriteLine("Successfully uploaded " + objectName );
}
catch (MinioException e)
{
Console.WriteLine("File Upload Error: {0}", e.Message);
}
}
}
}
Running MinIO Client 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.
//Cases.MakeBucket.Run(minioClient, bucketName).Wait();
- Run the Minio.Client.Examples project from Visual Studio
On Linux
Setting .NET SDK on Linux (Ubuntu 22.04)
NOTE: minio-dotnet requires .NET 6.x SDK to build on Linux.
- Install .Net SDK
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-6.0
Running Minio.Examples
- Clone this project.
$ git clone https://github.com/minio/minio-dotnet && cd minio-dotnet
- 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.
//Cases.MakeBucket.Run(minioClient, bucketName).Wait();
dotnet build --configuration Release --no-restore
dotnet pack ./Minio/Minio.csproj --no-build --configuration Release --output ./artifacts
dotnet test ./Minio.Tests/Minio.Tests.csproj
Bucket Operations
- MakeBucket.cs
- ListBuckets.cs
- BucketExists.cs
- RemoveBucket.cs
- ListObjects.cs
- ListIncompleteUploads.cs
- ListenBucketNotifications.cs
Bucket policy Operations
Bucket notification Operations
File Object Operations
Object Operations
Presigned Operations
Client Custom Settings
Explore Further
Showing the top 20 packages that depend on Minio.
Packages | Downloads |
---|---|
Quantum.Framework.WebApp
Package Description
|
48 |
Quantum.Framework.WebApp
Package Description
|
49 |
Quantum.Framework.WebApp
Package Description
|
52 |
Quantum.Framework.WebApp
Package Description
|
55 |
Quantum.Framework.WebApp
Package Description
|
59 |
Quantum.Framework.WebApp
Package Description
|
62 |
Quantum.Framework.WebApp
Package Description
|
71 |
Quantum.Framework.WebApp
Package Description
|
73 |
Quantum.Framework.WebApp
Package Description
|
112 |
Quantum.Framework.WebApp
Package Description
|
142 |
Quantum.Framework.WebApp
Package Description
|
157 |
Quantum.Framework.WebApp
提供TMS/WMS/OMS/AMS等共享的组件
|
49 |
Quantum.Framework.WebApp
提供TMS/WMS/OMS/AMS等共享的组件
|
50 |
Quantum.Framework.WebApp
提供TMS/WMS/OMS/AMS等共享的组件
|
52 |
Quantum.Framework.WebApp
提供TMS/WMS/OMS/AMS等共享的组件
|
53 |
Quantum.Framework.WebApp
提供TMS/WMS/OMS/AMS等共享的组件
|
54 |
Quantum.Framework.WebApp
提供TMS/WMS/OMS/AMS等共享的组件
|
166 |
.NET 6.0
- CommunityToolkit.HighPerformance (>= 8.1.0)
- System.Reactive.Linq (>= 5.0.0)
- System.IO.Hashing (>= 7.0.0)
.NET Standard 2.0
- System.ValueTuple (>= 4.5.0)
- System.Text.Json (>= 7.0.2)
- System.Security.Cryptography.Algorithms (>= 4.3.1)
- System.Reactive.Linq (>= 5.0.0)
- System.Net.Primitives (>= 4.3.1)
- System.IO.Hashing (>= 7.0.0)
- System.Net.Http (>= 4.3.4)
- CommunityToolkit.HighPerformance (>= 8.1.0)
- Microsoft.CSharp (>= 4.7.0)
.NET 7.0
- System.Reactive.Linq (>= 5.0.0)
- System.IO.Hashing (>= 7.0.0)
- CommunityToolkit.HighPerformance (>= 8.1.0)
Version | Downloads | Last updated |
---|---|---|
6.0.3 | 1 | 11/04/2024 |
6.0.2 | 355 | 03/14/2024 |
6.0.1 | 0 | 11/10/2023 |
6.0.0 | 6 | 10/12/2023 |
5.0.2 | 0 | 10/19/2024 |
5.0.0 | 8 | 06/16/2023 |
4.0.6 | 0 | 10/29/2022 |
4.0.5 | 7 | 06/16/2023 |
4.0.4 | 0 | 06/11/2022 |
4.0.3 | 0 | 05/16/2022 |
4.0.2 | 0 | 04/09/2022 |
4.0.1 | 7 | 04/23/2023 |
3.1.13 | 0 | 05/28/2020 |
3.1.12 | 0 | 05/01/2020 |
3.1.11 | 0 | 04/14/2020 |
3.1.10 | 0 | 03/14/2020 |
3.1.9 | 0 | 01/08/2020 |
3.1.8 | 0 | 12/13/2019 |
3.1.7 | 0 | 10/30/2019 |
3.1.6 | 0 | 10/11/2019 |
3.1.5 | 0 | 09/25/2019 |
3.1.4 | 0 | 09/06/2019 |
3.1.3 | 4 | 04/23/2023 |
3.1.2 | 0 | 09/04/2019 |
3.1.1 | 0 | 08/09/2019 |
3.0.12 | 0 | 07/03/2019 |
3.0.11 | 0 | 06/12/2019 |
3.0.10 | 0 | 05/08/2019 |
3.0.9 | 4 | 04/23/2023 |
3.0.8 | 0 | 03/20/2019 |
3.0.7 | 0 | 03/13/2019 |
3.0.6 | 0 | 03/06/2019 |
3.0.5 | 0 | 02/27/2019 |
3.0.4 | 0 | 02/13/2019 |
3.0.2 | 0 | 01/18/2019 |
3.0.1 | 9 | 04/23/2023 |
2.0.7 | 0 | 12/19/2018 |
2.0.6 | 0 | 11/06/2018 |
2.0.5 | 0 | 10/05/2018 |
2.0.4 | 0 | 09/22/2018 |
2.0.2 | 0 | 09/15/2018 |
2.0.1 | 7 | 04/23/2023 |
2.0.0 | 0 | 07/24/2018 |
1.1.1 | 0 | 04/06/2018 |
1.1.0 | 0 | 03/20/2018 |
1.0.5 | 0 | 12/23/2017 |
1.0.4 | 9 | 04/23/2023 |
1.0.2 | 0 | 08/29/2017 |
1.0.1 | 0 | 08/07/2017 |
1.0.0 | 0 | 05/17/2017 |
0.2.0 | 0 | 08/22/2015 |