ByteShelfClient 1.1.0
See the version list below for details.
dotnet add package ByteShelfClient --version 1.1.0
NuGet\Install-Package ByteShelfClient -Version 1.1.0
<PackageReference Include="ByteShelfClient" Version="1.1.0" />
<PackageVersion Include="ByteShelfClient" Version="1.1.0" />
<PackageReference Include="ByteShelfClient" />
paket add ByteShelfClient --version 1.1.0
#r "nuget: ByteShelfClient, 1.1.0"
#:package ByteShelfClient@1.1.0
#addin nuget:?package=ByteShelfClient&version=1.1.0
#tool nuget:?package=ByteShelfClient&version=1.1.0
ByteShelf
ByteShelf is a comprehensive multi-tenant file storage solution built with .NET 8. It provides a scalable, secure, and efficient way to store and manage files with automatic chunking, tenant isolation, and quota management.
๐๏ธ Architecture Overview
ByteShelf consists of several interconnected projects that work together to provide a complete file storage solution:
โโโโโโโโโโโโโโโโโโโ HTTP/REST โโโโโโโโโโโโโโโโโโโ
โ โ โโโโโโโโโโโโโโโโบโ โ
โ ByteShelfClient โ โ ByteShelf โ
โ (Client Lib) โ โ (API Server) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ
โ โ
โโโโโโโโโโโโโ โโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ByteShelfCommon โ
โ (Shared Data Structures) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฆ Project Structure
Core Projects
Project | Purpose | Description |
---|---|---|
ByteShelf | API Server | Main HTTP API server with multi-tenant support, authentication, and file storage |
ByteShelfClient | Client Library | .NET client library for easy integration with the ByteShelf API |
ByteShelfCommon | Shared Library | Common data structures, interfaces, and models used across all projects |
Test Projects
Project | Purpose | Description |
---|---|---|
ByteShelf.Tests | Unit Tests | Unit tests for the API server components |
ByteShelfClient.Tests | Client Tests | Unit tests for the client library |
ByteShelfCommon.Tests | Common Tests | Unit tests for shared data structures |
ByteShelf.Integration.Tests | Integration Tests | End-to-end integration tests for the complete system |
๐ Key Features
Multi-Tenant Architecture
- Tenant Isolation: Each tenant's files are completely isolated
- Per-Tenant Quotas: Configurable storage limits per tenant
- API Key Authentication: Secure access with tenant-specific API keys
- Admin Management: Administrative interface for tenant management
File Storage
- Automatic Chunking: Large files are automatically split into configurable chunks
- Streaming Support: Efficient memory usage for large files
- Metadata Storage: JSON-based metadata with file information
- Content Types: Full MIME type support
Developer Experience
- RESTful API: Standard HTTP endpoints for all operations
- Swagger Documentation: Auto-generated API documentation
- C# Client Library: Easy-to-use .NET client
- Comprehensive Testing: Full test coverage across all components
๐ ๏ธ Quick Start
Prerequisites
- .NET 8.0 SDK
- Visual Studio 2022 or VS Code
1. Build the Solution
dotnet build
2. Run the API Server
cd ByteShelf
dotnet run
The server will start on https://localhost:7001
with Swagger documentation available at /swagger
.
3. Use the Client Library
using HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://localhost:7001");
// Create client with tenant API key
IShelfFileProvider provider = new HttpShelfFileProvider(httpClient, "your-api-key");
// Upload a file
using FileStream fileStream = File.OpenRead("example.txt");
Guid fileId = await provider.WriteFileAsync("example.txt", "text/plain", fileStream);
// Download a file
ShelfFile file = await provider.ReadFileAsync(fileId);
using Stream content = file.GetContentStream();
// Process the file content...
๐ Configuration
Server Configuration
The API server is configured through appsettings.json
and environment variables:
{
"StoragePath": "/var/byteshelf/storage",
"ChunkConfiguration": {
"ChunkSizeBytes": 1048576
}
}
Tenant Configuration
Tenants are managed through an external JSON file with hot-reload support:
{
"RequireAuthentication": true,
"Tenants": {
"admin": {
"ApiKey": "admin-secure-api-key-here",
"StorageLimitBytes": 0,
"DisplayName": "System Administrator",
"IsAdmin": true
},
"tenant1": {
"ApiKey": "tenant1-secure-api-key-here",
"StorageLimitBytes": 1073741824,
"DisplayName": "Tenant 1",
"IsAdmin": false
}
}
}
Environment Variables
# Set tenant configuration file path
export BYTESHELF_TENANT_CONFIG_PATH=/etc/byteshelf/tenants.json
# Set storage path
export BYTESHELF_STORAGE_PATH=/var/byteshelf/storage
# Set chunk size
export ChunkConfiguration__ChunkSizeBytes=2097152
๐งช Testing
Run All Tests
dotnet test
Run Specific Test Projects
# Unit tests
dotnet test ByteShelf.Tests
dotnet test ByteShelfClient.Tests
dotnet test ByteShelfCommon.Tests
# Integration tests
dotnet test ByteShelf.Integration.Tests
๐ API Documentation
Core Endpoints
GET /api/files
- List all files for the authenticated tenantGET /api/files/{fileId}/metadata
- Get file metadataPOST /api/files/metadata
- Create file metadataPUT /api/chunks/{chunkId}
- Upload a chunkGET /api/chunks/{chunkId}
- Download a chunkDELETE /api/files/{fileId}
- Delete a file and all its chunks
Admin Endpoints
GET /api/admin/tenants
- List all tenants with usage informationPOST /api/admin/tenants
- Create a new tenantPUT /api/admin/tenants/{tenantId}/storage-limit
- Update tenant storage limitDELETE /api/admin/tenants/{tenantId}
- Delete tenant
Configuration Endpoints
GET /api/config/chunk-size
- Get chunk size configurationGET /api/tenant/info
- Get tenant information including admin statusGET /api/tenant/storage
- Get storage usage for authenticated tenantGET /api/tenant/storage/can-store
- Check if tenant can store a file of given size
๐ Security
Authentication
- API Key Authentication: All requests require a valid API key
- Tenant Isolation: Files are completely isolated between tenants
- Quota Enforcement: Storage limits are enforced per tenant
- Admin Privileges: Admin tenants have additional management capabilities
Best Practices
- Use strong, cryptographically secure API keys
- Store API keys in environment variables
- Use HTTPS in production environments
- Regularly rotate API keys
- Monitor API access for suspicious activity
๐ Deployment
See DEPLOYMENT.md for detailed deployment instructions, including:
- Docker deployment
- Linux service setup
- Production configuration
- Performance tuning
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
dotnet test
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License.
๐ Documentation
- ByteShelf API Server - Detailed documentation for the API server
- ByteShelfClient - Client library documentation
- ByteShelfCommon - Shared library documentation
- Deployment Guide - Production deployment instructions
Product | Versions 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- ByteShelfCommon (>= 1.1.0)
- System.Net.Http.Json (>= 9.0.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ByteShelfClient:
Package | Downloads |
---|---|
EasyReasy.ByteShelfProvider
Enables resources from ByteShelf for EasyReasy |
GitHub repositories
This package is not used by any popular GitHub repositories.