Sindika.AspNet.Storage 1.0.0

dotnet add package Sindika.AspNet.Storage --version 1.0.0                
NuGet\Install-Package Sindika.AspNet.Storage -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sindika.AspNet.Storage" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sindika.AspNet.Storage --version 1.0.0                
#r "nuget: Sindika.AspNet.Storage, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sindika.AspNet.Storage as a Cake Addin
#addin nuget:?package=Sindika.AspNet.Storage&version=1.0.0

// Install Sindika.AspNet.Storage as a Cake Tool
#tool nuget:?package=Sindika.AspNet.Storage&version=1.0.0                

Sindika.AspNet.Storage

Sindika.AspNet.Storage is a flexible and extensible .NET library designed to simplify working with various storage providers. It supports local storage as well as popular cloud storage providers such as MinIO, DigitalOcean Space, Wasabi, Azure Blob Storage, and Google Cloud Storage. With its unified interface and modular architecture, it provides an effortless way to integrate and manage storage in your .NET applications.

Features

  • Unified Interface: Access multiple storage providers with a common interface.
  • Support for Multiple Providers:
    • Local Storage
    • MinIO
    • DigitalOcean Spaces
    • Wasabi
    • Google Cloud Storage (GCP)
    • Azure Blob Storage
  • Asynchronous Operations: All methods are fully asynchronous, ensuring scalability and performance.
  • Dependency Injection Ready: Easy integration with ASP.NET Core's dependency injection system.
  • Health Check: Built-in support to test the storage connection at runtime.

Installation

Install the package via NuGet using the following command:

dotnet add package Sindika.AspNet.Storage

Usage

Configuration

Configure your appsettings.json to specify the storage provider and its settings. The Storage:Provider key should be set to the storage provider you want to use (e.g., MinIO, Local, etc.). Below is an example configuration:

"Storage": {
  "Provider": "MinIO", // Choose the desired provider (e.g., MinIO, Local, etc.)
  "Local": {
    "RootPath": "D:/"
  },
  "MinIO": {
    "AccessKey": "minio-access-key",
    "SecretKey": "minio-secret-key",
    "BucketName": "minio-bucket",
    "EndpointURL": "https://minio-url.com",
    "Region": "idn",
    "SessionToken": ""
  },
  "DigitalOceanSpace": {
    "AccessKey": "dos-access-key",
    "SecretKey": "dos-secret-key",
    "BucketName": "dos-bucket",
    "Region": "idn",
    "SessionToken": ""
  },
  "Wasabi": {
    "AccessKey": "wasabi-access-key",
    "SecretKey": "wasabi-secret-key",
    "BucketName": "wasabi-bucket",
    "EndpointURL": "https://wasabi-url.com",
    "SessionToken": ""
  },
  "GCP": {
    "BucketName": "gcp-bucket",
    "CredentialsFilePath": "gcp.json"
  },
  "Azure": {
    "ConnectionString": "azure.blob://account=account_name;key=secret_value"
  }
}

Program.cs Configuration

Register the storage service in your Program.cs file by calling the extension method AddStorages:

var builder = WebApplication.CreateBuilder(args);

// Add storage services
builder.Services.AddStorages(builder.Configuration);

var app = builder.Build();

// Other middleware

app.Run();

Health Check for Storage Connection

You can verify the storage connection during application startup by calling the TestConnectionAsync method:

using (var scope = app.Services.CreateScope())
{
    var serviceProvider = scope.ServiceProvider;
    await serviceProvider.GetRequiredService<IStorageService>().TestConnectionAsync();
}

Example Usage

Here is an example of how to use the IStorageService in your application:

public class FileService
{
    private readonly IStorageService _storageService;

    public FileService(IStorageService storageService)
    {
        _storageService = storageService;
    }

    public async Task UploadFileAsync(string filePath, Stream fileStream)
    {
        await _storageService.UploadFile(filePath, fileStream);
    }

    public async Task<Stream> GetFileAsync(string filePath)
    {
        return await _storageService.GetFile(filePath);
    }
}

Supported Providers

  • Local Storage: Stores files in the local file system.
  • MinIO: High-performance object storage with S3 compatibility.
  • DigitalOcean Space: Scalable object storage solution.
  • Wasabi: Affordable cloud storage with S3 compatibility.
  • Google Cloud Storage: Secure and highly durable object storage.
  • Azure Blob Storage: Massively scalable object storage.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests for improvements and bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 92 1/20/2025