Integrate Qiniu upload service and update configuration
- Added Qiniu configuration options to .env.example and config.go for file uploads. - Refactored main.go to include new Qiniu service and upload handler. - Updated route registration to accommodate the new upload handler. - Enhanced documentation to include references for Qiniu upload functionality. - Removed legacy authentication handler and services to streamline the codebase.
This commit is contained in:
@@ -14,6 +14,7 @@ type Config struct {
|
||||
Database DatabaseConfig
|
||||
JWT JWTConfig
|
||||
ShortVideo ShortVideoConfig
|
||||
Qiniu QiniuConfig
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@@ -40,6 +41,18 @@ type ShortVideoConfig struct {
|
||||
RequestTimeout time.Duration
|
||||
}
|
||||
|
||||
// QiniuConfig 用于七牛云(Kodo)直传相关配置。
|
||||
// 前端通常会向后端请求 upload token,然后直传文件到七牛。
|
||||
type QiniuConfig struct {
|
||||
AccessKey string
|
||||
SecretKey string
|
||||
Bucket string
|
||||
UploadURL string
|
||||
CDNDomain string
|
||||
KeyPrefix string
|
||||
TokenExpireSeconds int
|
||||
}
|
||||
|
||||
var AppConfig *Config
|
||||
|
||||
func LoadConfig() {
|
||||
@@ -69,6 +82,15 @@ func LoadConfig() {
|
||||
FreeDailyQuota: getEnvAsInt("SHORT_VIDEO_FREE_QUOTA", 20),
|
||||
RequestTimeout: time.Duration(getEnvAsInt("SHORT_VIDEO_TIMEOUT_SECONDS", 5)) * time.Second,
|
||||
},
|
||||
Qiniu: QiniuConfig{
|
||||
AccessKey: getEnv("QINIU_ACCESS_KEY", ""),
|
||||
SecretKey: getEnv("QINIU_SECRET_KEY", ""),
|
||||
Bucket: getEnv("QINIU_BUCKET", ""),
|
||||
UploadURL: getEnv("QINIU_UPLOAD_URL", "https://upload.qiniup.com"),
|
||||
CDNDomain: getEnv("QINIU_CDN_DOMAIN", ""),
|
||||
KeyPrefix: getEnv("QINIU_KEY_PREFIX", "uploads/"),
|
||||
TokenExpireSeconds: getEnvAsInt("QINIU_TOKEN_EXPIRE_SECONDS", 300),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user