I’ve been needing to access the AWS S3 API recently as part of a project and although there’s a pretty good client already available it didn’t quite meet my needs so I decided I needed to build my own client based on RestSharp.

Unfortunatly although the API is pretty simple to get to grips with, authenticating requests to it isn’t. After a bit of searching, I discovered that MinIO also use RestSharp and have created an authenticator for it so I based my code on theirs with a couple of tweaks.

My code can be found here, and I’ve added a service collection extension to help with adding a global RestSharp client via Dependency Injection.

private IServiceCollection ConfigureServices(IServiceCollection services)
{
	services
		.AddLogging(loggingBuilder =>
			loggingBuilder.AddSerilog(dispose: true)
		);

	services.AddAwsRestClient("<MY ACCESS KEY>", "<MY SECRET KEY>");

	return services;
}

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *