Storage Service .NET / Dịch vụ Lưu trữ .NET
EN: Microservice for file storage management supporting MinIO and Aliyun OSS.
VI: Microservice quản lý lưu trữ file hỗ trợ MinIO và Aliyun OSS.
Features / Tính năng
- Multi-provider storage: MinIO (S3-compatible) and Aliyun OSS
- Provider switching: Switch providers via environment variable
- File CRUD operations: Upload, download, delete, list files
- Pre-signed URLs: Secure time-limited download/upload URLs
- User quotas: Storage capacity and file count limits
- Inter-service auth: JWT validation via IAM Service
Architecture / Kiến trúc
Quick Start / Bắt đầu nhanh
Prerequisites / Yêu cầu
- .NET 10 SDK
- Docker & Docker Compose
- PostgreSQL (or Neon)
- MinIO (or Aliyun OSS)
Run with Docker / Chạy với Docker
Access at: http://localhost:5002/swagger
Run locally / Chạy local
Configuration / Cấu hình
| Variable |
Description |
Default |
Storage__Provider |
Provider: minio or aliyun |
minio |
Storage__DefaultBucket |
Default bucket name |
storage |
Storage__MinIO__Endpoint |
MinIO endpoint |
localhost:9000 |
Storage__MinIO__AccessKey |
MinIO access key |
- |
Storage__MinIO__SecretKey |
MinIO secret key |
- |
Storage__AliyunOSS__Endpoint |
OSS endpoint |
- |
Storage__AliyunOSS__AccessKeyId |
OSS access key |
- |
Storage__AliyunOSS__AccessKeySecret |
OSS secret key |
- |
IamService__BaseUrl |
IAM Service URL |
http://localhost:5001 |
API Endpoints
Files
| Method |
Endpoint |
Description |
POST |
/api/v1/files/upload |
Upload file via backend |
GET |
/api/v1/files |
List user files with pagination |
GET |
/api/v1/files/{id} |
Get file metadata by ID |
GET |
/api/v1/files/{id}/download-url |
Get download URL (presigned for private) |
DELETE |
/api/v1/files/{id} |
Soft delete file |
Direct Upload (Recommended)
| Method |
Endpoint |
Description |
POST |
/api/v1/storage/sign-upload |
Get pre-signed PUT URL |
POST |
/api/v1/storage/confirm-upload |
Confirm upload and save metadata |
File Sharing
| Method |
Endpoint |
Description |
POST |
/api/v1/files/{id}/share |
Create share link for file |
GET |
/api/v1/files/shared/{token} |
Access file via share token |
DELETE |
/api/v1/files/{id}/share |
Revoke share link |
Quota
| Method |
Endpoint |
Description |
GET |
/api/v1/quota |
Get current user quota |
GET |
/api/v1/quota/me |
Get quota for authenticated user |
Note: For private/shared files, download-url returns a pre-signed URL with AWS Signature V4. See docs/en/README.md for details.
Database Migrations / Migration Database
Testing / Kiểm thử
License
MIT