Yaver.ObjectStorage 1.0.0

dotnet add package Yaver.ObjectStorage --version 1.0.0
                    
NuGet\Install-Package Yaver.ObjectStorage -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="Yaver.ObjectStorage" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Yaver.ObjectStorage" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Yaver.ObjectStorage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Yaver.ObjectStorage --version 1.0.0
                    
#r "nuget: Yaver.ObjectStorage, 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.
#addin nuget:?package=Yaver.ObjectStorage&version=1.0.0
                    
Install Yaver.ObjectStorage as a Cake Addin
#tool nuget:?package=Yaver.ObjectStorage&version=1.0.0
                    
Install Yaver.ObjectStorage as a Cake Tool

Yaver.ObjectStorage

A .NET library for managing object storage operations with Cloudflare R2 and image processing capabilities.

Features

  • Object Storage Integration

    • Public and private storage support
    • File upload/download operations
    • Directory listing
    • File existence checks
    • File deletion
  • Image Processing

    • Automatic image optimization
    • WebP conversion
    • Multiple variant generation
    • Thumbnail creation
    • Image format detection
  • Built-in Integrations

    • Cloudflare R2 Storage
    • ASP.NET Core support
    • Dependency Injection
    • Swagger/OpenAPI documentation

Installation

dotnet add package Yaver.ObjectStorage

Configuration

Add storage configuration to your

appsettings.json

:

{
  "PUBLIC_OBJECT_STORAGE": {
    "ACCESS_KEY": "your-access-key",
    "SECRET_KEY": "your-secret-key",
    "BUCKET_NAME": "your-bucket",
    "ENDPOINT": "your-r2-endpoint"
  },
  "PRIVATE_OBJECT_STORAGE": {
    "ACCESS_KEY": "your-access-key",
    "SECRET_KEY": "your-secret-key",
    "BUCKET_NAME": "your-bucket",
    "ENDPOINT": "your-r2-endpoint"
  }
}

Usage

Service Registration

builder.Services.AddObjectStorages(builder.Configuration);

Basic File Operations

public class StorageService
{
    private readonly IS3Client _client;

    public StorageService(IS3ClientFactory factory)
    {
        _client = factory.CreateClient("public"); // or "private"
    }

    public async Task UploadFileAsync(IFormFile file, string key)
    {
        await _client.PutFileAsync(file, key);
    }

    public async Task<Stream> DownloadFileAsync(string fileName)
    {
        return await _client.GetFileStreamAsync(fileName);
    }
}

Image Processing

// Upload with image variants
await _client.PutImageWithVariantsAsync(
    file,
    key: "images/profile",
    variants: new[] {
        new ImageVariant("thumbnail", Width: 150, Height: 150),
        new ImageVariant("medium", Width: 800),
        new ImageVariant("large", Width: 1200)
    }
);

Sample API

The solution includes a sample API project demonstrating:

  • File upload endpoints
  • Image processing
  • Public/Private storage configuration
  • Swagger integration

Run the sample:

cd sample/Sample.Api
dotnet run

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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 216 a month ago