Using Amazon S3 for .NET Core 3.1 with MinIO Server

Amazon Simple Storage Service is a cloud server storage service which you can use basically to store anything.

MinIO is also a free object storage that is compatible with Amazon S3. So you can use MinIO on your development environment to test rather than sending the objects to Amazon S3.

You can follow Quickstart Guide for setting up MinIO.

MiniO has a documentation for .NET and it is straight forward. AWS also has a documentation for .NET Core. So, if you want to use it for .NET Core, you have to compose these two into one. This is what we are going to do in here:

All the in-line strings should be in appsettings.json:

So in addition to AccessKey, SecretKey, ServiceURL; I added Profile and Region.

In AWS documentation, these settings are directly being used to create a client. But if we do that, we couldn’t set ForcePathStyle=true. Which is necessary to work with MinIO. Also AWS injecting the service in Startup, right after it. But we need to edit the configurations before.

If you notice there is a AuthenticationRegion instead of RegionEndpoint. This was tricky, because first I used RegionEndpoint, but then I get lots of the following error:

The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'us-west-2'

So after that I searched a little, and found out that I should be using AuthenticationRegion if I want to inject service and use it everywhere.

Setup is done like that. For all AWS processes, I created a service called AWSService and injected right after AmazonS3. You can use this method to test if your service is working.

How to use AWS without MinIO?

If you want to use directly AWS, you can use it like in the documentation. In that case, you can set up credentials like following:

AWS only reads values like Region, Profile, ProfilesLocation. You can check options from here: ConfigurationExtensions.cs

--

--

--

Sitecore Developer at Namics-A Merkle Company

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Visualize the GNSS messages by RVIZ plugin, ROS

Character Stats/Attributes in Unity (pt. 2) — Additive Modifiers & Optimizations

16 decentralized apps you may see this year

The Fundamental Problems with cross-platform frameworks

Kickstart Your Tech Training With a Free Week on Cloud Academy

Free Week on Cloud Academy

Day 21 as a NASA JPL intern on the Psyche Mission

Python 100 projects in 100 days — Learning Journal

Du Recorder Mod Apk No Watermark Download 2022

Du Recorder Mod Apk No Watermark Download 2022

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tutku Can Yalçın

Tutku Can Yalçın

Sitecore Developer at Namics-A Merkle Company

More from Medium

Azure Functions + esbuild = 😍🤯

Container Shell Pattern

Connecting to Aws RDS database with IAM authentication in NHibernate with C# .net

Deploy an Angular application with Azure app service