添加本地上传的功能
This commit is contained in:
@@ -9,15 +9,31 @@ import (
|
||||
|
||||
// Config 应用配置
|
||||
type Config struct {
|
||||
Database *DatabaseConfig `json:"database"`
|
||||
OSS *OSSConfig `json:"oss"`
|
||||
Redis *RedisConfig `json:"redis"`
|
||||
CORS *CORSConfig `json:"cors"`
|
||||
MinIO *MinIOConfig `json:"minio"`
|
||||
Email *EmailConfig `json:"email"`
|
||||
SMS *SMSConfig `json:"sms"`
|
||||
Logger *LoggerConfig `json:"logger"`
|
||||
RateLimit *RateLimitConfig `json:"rateLimit"`
|
||||
Database *DatabaseConfig `json:"database"`
|
||||
OSS *OSSConfig `json:"oss"`
|
||||
Redis *RedisConfig `json:"redis"`
|
||||
CORS *CORSConfig `json:"cors"`
|
||||
MinIO *MinIOConfig `json:"minio"`
|
||||
Local *LocalStorageConfig `json:"localStorage"`
|
||||
Email *EmailConfig `json:"email"`
|
||||
SMS *SMSConfig `json:"sms"`
|
||||
Logger *LoggerConfig `json:"logger"`
|
||||
RateLimit *RateLimitConfig `json:"rateLimit"`
|
||||
}
|
||||
|
||||
// LocalStorageConfig 本地存储配置
|
||||
// 用于将文件保存到本地文件夹(适合开发环境、单机部署等场景)
|
||||
type LocalStorageConfig struct {
|
||||
// BaseDir 本地文件保存根目录(必填)
|
||||
// 示例: "./uploads" 或 "/var/app/uploads"
|
||||
BaseDir string `json:"baseDir"`
|
||||
|
||||
// PublicURL 对外访问URL(可选)
|
||||
// 1) 若包含 "{objectKey}" 占位符,则会替换为 url.QueryEscape(objectKey)
|
||||
// 示例: "http://localhost:8080/file?key={objectKey}" (配合 ProxyHandler 使用)
|
||||
// 2) 若不包含占位符,则作为URL前缀,自动拼接 objectKey
|
||||
// 示例: "http://localhost:8080/static/" => "http://localhost:8080/static/<objectKey>"
|
||||
PublicURL string `json:"publicURL"`
|
||||
}
|
||||
|
||||
// DatabaseConfig 数据库配置
|
||||
@@ -439,6 +455,11 @@ func (c *Config) GetMinIO() *MinIOConfig {
|
||||
return c.MinIO
|
||||
}
|
||||
|
||||
// GetLocalStorage 获取本地存储配置
|
||||
func (c *Config) GetLocalStorage() *LocalStorageConfig {
|
||||
return c.Local
|
||||
}
|
||||
|
||||
// GetEmail 获取邮件配置
|
||||
func (c *Config) GetEmail() *EmailConfig {
|
||||
return c.Email
|
||||
|
||||
Reference in New Issue
Block a user