How verizhang/file-manager works
File Manager supports simple and multipart direct-to-object-storage uploads, metadata and download/delete operations, and asynchronous virus scanning. The main path is client → API → service → storage/metadata; upload completion publishes an event consumed by the worker, which streams the object to a scanner and records the scan result. README and excerpts support the principal flows; some links involving unsampled modules are omitted where their call sites are not shown.
Main entry points: file_service_impl.go File workflows · virusscannerworker/main.go Scanner worker · file_handler.go File handler · api/main.go API composition
Components 19
API access
- HTTP gateway
internal/server/gateway.go - gRPC server
internal/server/grpc.go - File handler
internal/handler/file_handler.go - Request validation
internal/handler/file_validation.go - API composition
cmd/api/main.go - File API contract
proto/file/v1/file.proto
File workflows
- File workflows
internal/service/file_service_impl.go - File lifecycle
internal/model/file.go
Metadata persistence
- MySQL repository
internal/repository/mysql/file_repository.go - MySQL
Virus scanning
- Scanner worker
cmd/virusscannerworker/main.go - Event consumer
internal/consumer/consumer.go - ClamAV scanner
pkg/virusscanner/clamav/scanner.go
External integrations
- S3 storage adapter
pkg/storage/s3/storage.go - S3-compatible storage
- RabbitMQ adapter
pkg/messaging/rabbitmq/rabbitmq.go - RabbitMQ
- ClamAV
Other components
- Client
Connections 26
- Client → HTTP gateway: sends HTTP
README.md - Client → gRPC server: calls gRPC
README.md - HTTP gateway → gRPC server: routes requests
internal/server/gateway.go - API composition → HTTP gateway: starts
cmd/api/main.go - API composition → gRPC server: starts
cmd/api/main.go - API composition → File handler: constructs
cmd/api/main.go - gRPC server → File handler: registers
internal/server/grpc.go - File handler → Request validation: validates with
internal/handler/file_handler.go - File handler → File workflows: calls
internal/handler/file_handler.go - File handler → File API contract: implements
- File workflows → File lifecycle: uses
internal/service/file_service_impl.go - File workflows → S3 storage adapter: requests object operations
internal/service/file_service_impl.go - S3 storage adapter → S3-compatible storage: reads and writes
README.md - File workflows → MySQL repository: persists metadata
internal/service/file_service_impl.go - MySQL repository → MySQL: reads and writes
README.md - API composition → MySQL repository: constructs
cmd/api/main.go - Scanner worker → Event consumer: registers handler
cmd/virusscannerworker/main.go - Event consumer → File workflows: calls scan
internal/consumer/consumer.go - Scanner worker → MySQL repository: constructs
cmd/virusscannerworker/main.go - Scanner worker → S3 storage adapter: constructs
cmd/virusscannerworker/main.go - Scanner worker → ClamAV scanner: constructs
cmd/virusscannerworker/main.go - File workflows → RabbitMQ adapter: publishes events
internal/service/file_service_impl.go - RabbitMQ adapter → RabbitMQ: publishes and consumes
pkg/messaging/rabbitmq/rabbitmq.go - Scanner worker → RabbitMQ adapter: subscribes
cmd/virusscannerworker/main.go - File workflows → ClamAV scanner: streams object to scan
internal/service/file_service_impl.go - ClamAV scanner → ClamAV: scans stream
README.md