Skip to content

An implementation of ASP.NET Core's FileProvider for AWS S3

License

Notifications You must be signed in to change notification settings

evorine/S3FileProvider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

S3FileProvider

S3FileProvider is an implementation of Microsoft.Extensions.FileProviders.Abstractions library for AWS S3.

Nuget

Library is published at Nuget.org as Evorine.FileSystem.S3FileProvider.

Examples

Creating a S3FileProvider instance is very simple:

var fileProvider = new S3FileProvider(amazonS3Service, bucketName);

Using S3 as static files in Asp.Net Core website

In Configure method:

public void Configure(IApplicationBuilder app)
{
    // ...
    
    var fileProvider = new S3FileProvider(amazonS3, "bucket-name");

    var staticFilesOption = new StaticFileOptions()
    {
        FileProvider = fileProvider
    };
    app.UseStaticFiles(staticFilesOption);
    
    // ...
}

For Amazon S3 Service instance:

var amazonS3 = new Amazon.S3.AmazonS3Client("awsAccessKeyId", "awsSecretAccessKey", Amazon.RegionEndpoint.USWest2);

Or if you have already registered Amazon S3 services in ConfigureServices method:

var amazonS3 = app.ApplicationServices.GetService<Amazon.S3.IAmazonS3>();

That's all!

ToDos:

  • Cancellation tokens
  • File and directory watch feature

Changes:

Version Beta2:

  • S3FileProvider.GetDirectoryContents and S3FileProvider.GetFileInfo throws ArgumentNullException if null passed as path.

About

An implementation of ASP.NET Core's FileProvider for AWS S3

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages