feat(upload): 接入媒体策略与日志选项
为上传服务注入 media.Policy 与 zap.Logger,对齐广场媒体校验。
This commit is contained in:
parent
715ace7ac6
commit
f708a86d5c
@ -5,7 +5,10 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"spark-server/internal/pkg/media"
|
||||
"spark-server/internal/pkg/ratelimit"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Presigner issues short-lived object-storage URLs. Infrastructure implements it.
|
||||
@ -23,6 +26,8 @@ type Options struct {
|
||||
Limit *ratelimit.Limiter
|
||||
Now func() time.Time
|
||||
Groups AvatarACL
|
||||
Media media.Policy
|
||||
Log *zap.Logger
|
||||
}
|
||||
|
||||
// Service issues upload/download credentials. HTTP and TCP share it.
|
||||
@ -32,6 +37,8 @@ type Service struct {
|
||||
limit *ratelimit.Limiter
|
||||
now func() time.Time
|
||||
groups AvatarACL
|
||||
media media.Policy
|
||||
log *zap.Logger
|
||||
}
|
||||
|
||||
func NewService(store Presigner, opt Options) *Service {
|
||||
@ -43,7 +50,11 @@ func NewService(store Presigner, opt Options) *Service {
|
||||
if clock == nil {
|
||||
clock = func() time.Time { return time.Now().UTC() }
|
||||
}
|
||||
return &Service{store: store, ttl: ttl, limit: opt.Limit, now: clock, groups: opt.Groups}
|
||||
log := opt.Log
|
||||
if log == nil {
|
||||
log = zap.NewNop()
|
||||
}
|
||||
return &Service{store: store, ttl: ttl, limit: opt.Limit, now: clock, groups: opt.Groups, media: opt.Media, log: log}
|
||||
}
|
||||
|
||||
func (s *Service) ready() bool {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user