A generic C# library for interacting with multiple cloud storage providers with a unified API interface.
- Multi-Provider Support: Upload, download, and manage files across various cloud storage services
- Consistent API: Same interface for all supported providers
- Extensible Architecture: Easily add support for new storage providers
- Dependency Injection Ready: Built for modern .NET applications
- Comprehensive Testing: Unit and integration test coverage
Provider | Status | Notes |
---|---|---|
AWS S3 | ✔️ | Full support |
Huawei OBS | ✔️ | Full support |
DigitalOcean | ✔️ | S3-compatible |
MinIO | ✔️ | S3-compatible |
Local Storage | ✔️ | For development/testing |
Azure Blob | ⌛ | Planned for next release |
Google Cloud | ⌛ | Planned for next release |
dotnet add package ObjectStorageService
// Configure in your Startup.cs
services.AddObjectStorage(Configuration);
// Inject and use in your services
public class MyService
{
private readonly IObjectStorageService _storage;
public MyService(IObjectStorageService storage)
{
_storage = storage;
}
public async Task UploadFileAsync(string bucket, string key, Stream data)
{
await _storage.UploadFileAsync(bucket, key, data);
}
}
{
"ObjectStorage": {
"Provider": "AwsS3", // or "HuaweiObs", "DigitalOcean", "MinIO", "Local"
"AccessKey": "your-access-key",
"SecretKey": "your-secret-key",
"Endpoint": "https://your-endpoint.com",
"Region": "us-east-1",
"LocalStoragePath": "/path/to/local/storage" // For local provider
}
}
-
Create a new class that implements
IObjectStorageService
-
Add your provider to the
StorageProvider
enum -
Update the factory/service registration
Example for MinIO (S3-compatible):
public class MinIOStorageService : BaseObjectStorageService
{
private readonly IAmazonS3 _s3Client;
public MinIOStorageService(ObjectStorageOptions options, ILogger<MinIOStorageService> logger)
: base(options, logger)
{
var config = new AmazonS3Config
{
ServiceURL = options.Endpoint,
ForcePathStyle = true, // Important for MinIO
Timeout = TimeSpan.FromSeconds(60),
MaxErrorRetry = 3
};
_s3Client = new AmazonS3Client(options.AccessKey, options.SecretKey, config);
}
// Implement required methods using _s3Client
// ...
}
Update the factory method:
services.AddTransient<IObjectStorageService>(provider =>
{
var options = provider.GetRequiredService<IOptions<ObjectStorageOptions>>().Value;
return options.Provider switch
{
StorageProvider.AwsS3 => new AwsS3StorageService(options, logger),
StorageProvider.MinIO => new MinIOStorageService(options, logger),
// ... other providers
_ => throw new InvalidOperationException($"Unsupported provider: {options.Provider}")
};
});
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature
) - Open a Pull Request
- Follow existing code style and patterns
- Include unit tests for new features
- Update documentation when adding new features
- Keep PRs focused on a single feature/bugfix
- Use descriptive commit messages
We're particularly interested in adding support for:
- Azure Blob Storage
- Google Cloud Storage
- Backblaze B2
- Alibaba Cloud OSS
- Advanced file metadata support
- Multi-part upload/download
- Client-side encryption
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License gives you the freedom to:
- Use the software for any purpose
- Modify the software to suit your needs
- Distribute the original or modified software
- Use the software in private or commercial projects
- Add Azure Blob Storage support
- Improve error handling and retry policies
- Add file metadata support
- Google Cloud Storage integration
- Client-side encryption
- Multi-part upload support
- Storage analytics
- Automatic provider failover
- Browser upload integration