本文 Ghost version: 4.32.1

安装 ghost-qcloud-cos 模块

使用命令安装

npm install ghost-qcloud-cos

在目录下创建文件夹

mkdir -p content/adapters/storage

content/adapters/storage创建cos-store.js

//  content/adapters/storage/cos-store.js
module.exports = require('ghost-qcloud-cos');

配置设置文件

config.production.json中添加

{
  "storage": {
    "active": "cos-store",
    "cos-store": {
      "baseUrl": "Base Url(Allowed to be empty)",
      "basePath": "图片存放路径,不填写默认为/ghost/content/images/",
      "rename": "是否重命名为 MD5 文件名,布尔值,默认为 false",
      "SecretId": "Secret Id",
      "SecretKey": "Secret Key",
      "Bucket": "xxxx-123456",
      "Region": "ap-chengdu"
    }
  }
}

重启一下

ghost restart

sudo systemctl restart ghost_yoursite-com # CentOS 要用这个

参考资料

https://github.com/ZhelinCheng/ghost-qcloud-cos