Skip to content

A nuget package which allows you to integrate S3 storage into your Web Application. Also, the library allows you to use localstack for debugging.

License

Notifications You must be signed in to change notification settings

maximgorbatyuk/AspNetCore.Aws.S3.Simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AspNetCore.Aws.S3.Simple

GitHub Workflow Status Nuget GitHub release (latest by date) GitHub

A nuget package which allows you to integrate S3 storage into your Web Application. Also, the library allows you to use localstack for debugging.

Installation

dotnet add package AspNetCore.Aws.S3.Simple

Demonstration

For simple demo, you need Docker installed in your PC. If you have it, then follow the instruction:

  1. Pull the repo
  2. run win-run.ps1 or unix-run.ps1 script
  3. Go to https://localhost:5001/swagger/index.html. There are two endpoints: /files/upload and /files/download.

How to install and setup

  1. Install the nuget package AspNetCore.Aws.S3.Simple;
  2. Create inheritors of IFileStorageBase.cs and AmazonS3StorageBase;
using S3.Integration.AmazonServices;
using S3.Integration.Contracts;
using S3.Integration.Settings;

public interface IAvatarsStorage : IFileStorageBase
{
}

public class AvatarsS3Storage : AmazonS3StorageBase, IAvatarsStorage
{
    public AvatarsS3Storage(
        S3StorageSettings configuration,
        IS3FileValidator fileValidator)
        : base(configuration, fileValidator, "user-avatars")
    {
    }
}
  1. Add settings in the Startul.cs or Program.cs file:
var builder = WebApplication.CreateBuilder(args);
// ...
builder.Services
    .AddS3Settings()
    .AddS3Storage<IAvatarsStorage, AvatarsS3Storage>();
  1. Add healthcheck settings (if necessary):
builder.Services
    .AddHealthChecks()
    .AddS3HealthChecks(builder.Configuration);
  1. Use the storage service

Roadmap

  • Add API for reading all files in the bucket
  • Storing private and public files

Sample project

CHeck out this sample Web.Api project and see how to use the nuget

Resources

About

A nuget package which allows you to integrate S3 storage into your Web Application. Also, the library allows you to use localstack for debugging.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published