Files
ai_dianshang/server/configs/config.oss.example.yaml

133 lines
4.0 KiB
YAML
Raw Normal View History

2025-11-17 13:32:54 +08:00
# 阿里云OSS配置示例
# 将此文件复制为 config.yaml 或 config.prod.yaml并填入你的实际配置信息
server:
port: 8080
mode: release
database:
driver: mysql
host: 127.0.0.1
port: 3306
username: root
password: "your-password"
dbname: ai_dianshang
charset: utf8mb4
parseTime: true
loc: Local
redis:
host: localhost
port: 6379
password: ""
db: 0
jwt:
secret: "your-jwt-secret-key-change-this-in-production"
expire: 7200
log:
level: info
filename: logs/app.log
maxSize: 100
maxAge: 30
maxBackups: 5
enableConsole: true
enableFile: true
format: json
enableCaller: true
enableOperation: true
enablePerf: true
perfThreshold: 1000
wechat:
appId: "your-wechat-appid"
appSecret: "your-wechat-appsecret"
wechatPay:
environment: "production"
appId: "your-wechat-appid"
mchId: "your-merchant-id"
apiV3Key: "your-api-v3-key-32-characters"
certPath: "certs/apiclient_cert.pem"
keyPath: "certs/apiclient_key.pem"
serialNo: "your-certificate-serial-number"
notifyUrl: "https://yourdomain.com/api/v1/payment/notify"
refundNotifyUrl: "https://yourdomain.com/api/refunds/callback"
# ========== 文件上传配置 ==========
upload:
maxImageSize: 5242880 # 5MB
maxFileSize: 10485760 # 10MB
imageTypes: [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"]
# 存储类型选择:
# - local: 本地存储(默认)
# - oss: 阿里云OSS
storageType: "oss"
# 本地存储配置storageType为local时使用
staticPath: "./static"
baseUrl: "https://yourdomain.com"
# 阿里云OSS配置storageType为oss时使用
oss:
# OSS访问域名Endpoint
# 根据你的Bucket所在地域选择
# - 华东1杭州oss-cn-hangzhou.aliyuncs.com
# - 华东2上海oss-cn-shanghai.aliyuncs.com
# - 华北1青岛oss-cn-qingdao.aliyuncs.com
# - 华北2北京oss-cn-beijing.aliyuncs.com
# - 华南1深圳oss-cn-shenzhen.aliyuncs.com
# 更多地域请参考https://help.aliyun.com/document_detail/31837.html
endpoint: "oss-cn-hangzhou.aliyuncs.com"
# AccessKey ID在阿里云控制台获取
# 建议使用RAM子账号的AccessKey并授予最小权限
accessKeyId: "your-access-key-id"
# AccessKey Secret在阿里云控制台获取
accessKeySecret: "your-access-key-secret"
# Bucket名称需要提前在OSS控制台创建
bucketName: "your-bucket-name"
# 文件存储基础路径(可选,建议设置以便文件分类管理)
# 例如dianshang/ 表示所有文件都存储在 dianshang/ 目录下
basePath: "dianshang/"
# 自定义域名(可选)
# 如果你配置了CDN加速域名或自定义域名填写这里
# 例如https://cdn.yourdomain.com
# 如果不填写将使用默认的OSS域名https://bucket-name.endpoint/
domain: ""
# ========== OSS配置说明 ==========
#
# 1. 创建OSS Bucket
# - 登录阿里云OSS控制台https://oss.console.aliyun.com/
# - 创建Bucket选择合适的地域和存储类型
# - 设置读写权限为"公共读"(如果需要直接访问)或"私有"使用签名URL访问
#
# 2. 获取AccessKey
# - 访问https://ram.console.aliyun.com/manage/ak
# - 建议创建RAM子账号只授予OSS相关权限AliyunOSSFullAccess
# - 获取AccessKey ID和AccessKey Secret
#
# 3. 配置跨域CORS
# - 在OSS控制台的Bucket设置中配置CORS规则
# - 允许的来源:* 或你的域名
# - 允许的方法GET, POST, PUT, DELETE, HEAD
# - 允许的Headers*
#
# 4. CDN加速可选但推荐
# - 在OSS控制台绑定自定义域名
# - 开启CDN加速以提升访问速度
# - 配置HTTPS证书
# - 将domain设置为你的CDN域名
#
# 5. 切换存储方式:
# - 修改 storageType 为 "local" 使用本地存储
# - 修改 storageType 为 "oss" 使用阿里云OSS
# - 系统支持降级OSS上传失败时自动切换到本地存储