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

3. 创建 Access Key
地址: https://console.bce.baidu.com/iam/#/iam/accesslist
如已有Access Key,则可跳过创建
4. 配置
修改 app.toml 下的cloudStore
[cloudStore]# 存储类型,填bos,即百度云对象存储storeType = "bos"# 存储绑定的域名,带 http:// 或 https:// ,可以为空。domain = "https://static.moredoc.mnt.ltd"# 百度云的 Access KeyaccessKey = "Access Key"# 百度云的 Secret KeysecretKey = "Secret Key"# 对象存储的bucketbucket = "moredoc-private"# 对象存储 endpoint,为访问域名 moredoc-private.gz.bcebos.com 去掉bucket的后半段endpoint = "gz.bcebos.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]# 存储类型,填bos,即百度云对象存储storeType = "bos"# 存储绑定的域名,带 http:// 或 https:// ,可以为空。domain = "https://static.moredoc.mnt.ltd"# 百度云的 Access KeyaccessKey = "Access Key"# 百度云的 Secret KeysecretKey = "Secret Key"# 对象存储的bucketbucket = "moredoc-private"# 对象存储 endpoint,为访问域名 moredoc-private.gz.bcebos.com 去掉bucket的后半段endpoint = "gz.bcebos.com"
