华为云对象存储 COS
当前,以演示站点域名moredoc.mnt.ltd和对象存储绑定的域名static.moredoc.mnt.ltd来作为配置演示,其他配置项仅作为参考。
步骤
1. 开通华为云对象存储OSS
地址:https://www.huaweicloud.com/product/obs.html
2. 创建私有 Bucket
地址:https://console.huaweicloud.com/console/#/obs/create

3. 创建访问密钥
地址: https://console.huaweicloud.com/iam/#/mine/accessKey
如已有访问密钥,则可跳过创建
4. 配置
修改 app.toml 下的cloudStore
[cloudStore]# 存储类型,填obs,即华为云对象存储storeType = "obs"# 存储绑定的域名,带 http:// 或 https:// ,可以为空。domain = "https://static.moredoc.mnt.ltd"# 华为云的 Access Key IdaccessKey = "Access Key Id"# 华为云的 Secret Access KeysecretKey = "Secret Access Key"# 对象存储的bucketbucket = "moredoc-private"# 对象存储 endpoint,进入 bucket 的【概览】可以看到endpoint = "obs.cn-south-1.myhuaweicloud.com"
5. 迁移与重启
迁移本地的 uploads和 documents 到对象存储
./moredoc migrateCloudstore
重启文库程序。
配置参考
完整配置参考示例如下:
# 程序运行级别:debug、info、warn、error,生产环境使用 info及其以上级别level = "debug"# 日志编码方式,支持:json、consolelogEncoding = "console"# 程序运行端口port = "8880"# 数据库配置[database]driver = "mysql"dsn = "root:root@tcp(localhost:3306)/moredoc?charset=utf8mb4&loc=Local&parseTime=true"showSQL = truemaxOpen = 10maxIdle = 10# JSON Web Token 配置[jwt]# 生成 token 的密钥,请务必修改!!!secret = "moredoc"# token 过期时间expireDays = 365[cloudStore]# 存储类型,填obs,即华为云对象存储storeType = "obs"# 存储绑定的域名,带 http:// 或 https:// ,可以为空。domain = "https://static.moredoc.mnt.ltd"# 华为云的 Access Key IdaccessKey = "Access Key Id"# 华为云的 Secret Access KeysecretKey = "Secret Access Key"# 对象存储的bucketbucket = "moredoc-private"# 对象存储 endpoint,进入 bucket 的【概览】可以看到endpoint = "obs.cn-south-1.myhuaweicloud.com"