Files
pos-system/services/storage-service-net
Ho Ngoc Hai 5c8764f63a docs(architecture): Update documentation for direct upload architecture and API endpoints
- Enhanced the architecture documentation to recommend direct upload over legacy proxy upload for improved performance and scalability.
- Added detailed comparisons of upload patterns, including throughput, memory usage, and latency.
- Updated API endpoint documentation to reflect new direct upload methods and their benefits.
- Included examples for direct upload flow and bucket directory structure to aid developers in implementation.
2026-01-13 21:17:55 +07:00
..

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

├── src/
│   ├── StorageService.API/           # Controllers, Commands, Queries
│   ├── StorageService.Domain/        # Entities, Repository interfaces
│   └── StorageService.Infrastructure/# Providers, DbContext, Repositories
└── tests/
    ├── StorageService.UnitTests/
    └── StorageService.FunctionalTests/

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

cd services/storage-service-net
docker-compose up -d

Access at: http://localhost:5002/swagger

Run locally / Chạy local

cd services/storage-service-net
dotnet run --project src/StorageService.API

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

Method Endpoint Description
POST /api/v1/files/upload Upload file
GET /api/v1/files List user files
GET /api/v1/files/{id} Get file by ID
GET /api/v1/files/{id}/download-url Get pre-signed download URL
DELETE /api/v1/files/{id} Delete file
GET /api/v1/quota Get user quota

Database Migrations / Migration Database

cd services/storage-service-net
dotnet ef migrations add InitialCreate --project src/StorageService.Infrastructure --startup-project src/StorageService.API
dotnet ef database update --project src/StorageService.Infrastructure --startup-project src/StorageService.API

Testing / Kiểm thử

# Unit tests
dotnet test tests/StorageService.UnitTests

# All tests
dotnet test

License

MIT