GithubHelp home page GithubHelp logo

ghost-oss-store's Introduction

Ghost Aliyun OSS Storage

NPM version

This Ghost custom storage module allows you to store media file with Aliyun OSS instead of storing at local machine.

Supported

  • 1.x
  • 0.x

Installation

Via NPM

  • Install Oss storage module

    npm install ghost-oss-store
    
  • Make the storage folder if it doesn't exist yet

    mkdir -p content/adapters/storage
    
  • Create a script named "oss-store.js", content as follow:

//  content/adapters/storage/oss-store.js

module.exports = require('ghost-oss-store');

Via Git

In order to replace the storage module, the basic requirements are:

  • Create a new folder inside /content called /storage

  • Clone this repo to /storage

    cd [path/to/ghost]/content/storage
    mkdir oss-store && cd oss-store
    git clone https://github.com/MT-Libraries/ghost-oss-store ./
    
  • Install dependencies

    npm install
    

Configuration

In your config.js file, you'll need to add a new storage block to whichever environment you want to change:

storage: {
  active: 'oss-store',
  'oss-store': {
    accessKeyId: 'accessKeyId',
    accessKeySecret: 'accessKeySecret',
    bucket: 'bucket',
    region: 'oss-cn-hangzhou',
    origin: 'https://www.thonatos.com/', // if you have bind custom domain to oss bucket. or false             
    fileKey: {
      safeString: true, // use Ghost safaString util to rename filename, e.g. Chinese to Pinyin
      prefix: 'ghost/',  // { String } will be formated by moment.js, using `[]` to escape,
      suffix: '' // { String } string added before file extname.
    }
  }
}

License

Read LICENSE

ghost-oss-store's People

Contributors

hxsf avatar raohai avatar thonatos avatar x-cold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ghost-oss-store's Issues

We have detected an unknown error in your custom storage adapter.

[2017-12-01 04:45:39] ERROR

NAME: IncorrectUsageError
MESSAGE: We have detected an unknown error in your custom storage adapter.

Ghost/content/adapters/storage/oss-store/index.js:9
} catch {
        ^

SyntaxError: Unexpected token {
    at createScript (vm.js:74:10)

Env: node v8.5.0

Error: Cannot find module '/var/lib/ghost/versions/1.23.0/core/server/adapters/storage/oss-store'

We cannot find your adapter in: /var/lib/ghost/content/adapters/storage/ or: /var/lib/ghost/versions/1.23.0/core/server/adapters/storage/
IncorrectUsageError: We detected a misuse. Please read the stack trace.
    at new IncorrectUsageError (/var/lib/ghost/versions/1.23.0/node_modules/ghost-ignition/lib/errors/index.js:79:23)
    at Object.getStorage (/var/lib/ghost/versions/1.23.0/core/server/adapters/storage/index.js:60:19)
    at setupSiteApp (/var/lib/ghost/versions/1.23.0/core/server/web/site/app.js:74:73)
    at setupParentApp (/var/lib/ghost/versions/1.23.0/core/server/web/parent-app.js:54:36)
    at /var/lib/ghost/versions/1.23.0/core/server/index.js:84:48
    at tryCatcher (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:638:18)
    at PromiseArray._resolve (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise_array.js:126:19)
    at PromiseArray._promiseFulfilled (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise_array.js:144:14)
    at Promise._settlePromise (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:574:26)
    at Promise._settlePromise0 (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:693:18)

Error: Cannot find module '/var/lib/ghost/versions/1.23.0/core/server/adapters/storage/oss-store'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.getStorage (/var/lib/ghost/versions/1.23.0/core/server/adapters/storage/index.js:57:42)
    at setupSiteApp (/var/lib/ghost/versions/1.23.0/core/server/web/site/app.js:74:73)
    at setupParentApp (/var/lib/ghost/versions/1.23.0/core/server/web/parent-app.js:54:36)
    at /var/lib/ghost/versions/1.23.0/core/server/index.js:84:48
    at tryCatcher (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise.js:638:18)
    at PromiseArray._resolve (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise_array.js:126:19)
    at PromiseArray._promiseFulfilled (/var/lib/ghost/versions/1.23.0/node_modules/bluebird/js/release/promise_array.js:144:14)

There is no "config.js" file in ghost 1.21.2

But there is no "config.js" file in ghost 1.21.2
how can i configure my oss-store
maybe config.[env].json?
if i configure config.production.json file ,then ghost can not restart!
Ghost-cli version 1.5.2
Ghost version 1.21.2

can you help me? thanyou very much

通过ghostcli安装的最新版本怎么配置oss-store?没有config.js文件呀~~

can't restart ghost or use any 'ghost - ***' command

Debug Information:
    OS: Ubuntu, v16.04
    Node Version: v8.10.0
    Ghost-CLI Version: 1.5.2
    Environment: production
    Command: 'ghost status'
An error occurred.
Message: 'Command failed: /bin/sh -c systemctl is-active ghost_mydomain-com
failed
Stack: Error: Command failed: /bin/sh -c systemctl is-active ghost_mydomain-com
failed
    at makeError (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:169:9)
    at module.exports.sync (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:338:15)
    at handleShell (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:116:9)
    at Function.module.exports.shellSync (/usr/lib/node_modules/ghost-cli/node_modules/execa/index.js:361:43)
    at SystemdProcessManager.isRunning (/usr/lib/node_modules/ghost-cli/extensions/systemd/systemd.js:88:19)
    at Instance.running (/usr/lib/node_modules/ghost-cli/lib/instance.js:120:34)
    at Instance.summary (/usr/lib/node_modules/ghost-cli/lib/instance.js:201:19)
    at instances.map (/usr/lib/node_modules/ghost-cli/lib/commands/ls.js:10:38)
    at Array.map (<anonymous>)
    at LsCommand.run (/usr/lib/node_modules/ghost-cli/lib/commands/ls.js:9:32)
    at precheck.then (/usr/lib/node_modules/ghost-cli/lib/command.js:159:52)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at Function.Module.runMain (module.js:695:11)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
Code: 3

there should return https url after upload a image

when I used this storage adapter, the image url always is http rather than https. when I check the OSS SDK documentation, it shows that we should add secure: true when creating OSS client. the documentation is here. I have submit a PR to resolve this, please help to review it. thanks.

配置完config.production.json后,出错无法打开,附production.error.log

{"name":"Log","hostname":"ubuntu","pid":27979,"level":50,"err":{"id":"8f2c4ed0-723c-11e8-9846-f9cf5235d1a3","domain":"https://www.wanily.com","code":"MODULE_NOT_FOUND","name":"IncorrectUsageError","statusCode":400,"level":"critical","message":"We detected a misuse. Please read the stack trace.","context":"We cannot find your adapter in: /www/wwwroot/wanily/content/adapters/storage/ or: /www/wwwroot/wanily/core/server/adapters/storage/","stack":"IncorrectUsageError: We detected a misuse. Please read the stack trace.\n at new IncorrectUsageError (/www/wwwroot/wanily/node_modules/ghost-ignition/lib/errors/index.js:79:23)\n at Object.getStorage (/www/wwwroot/wanily/core/server/adapters/storage/index.js:60:19)\n at setupSiteApp (/www/wwwroot/wanily/core/server/web/site/app.js:74:73)\n at setupParentApp (/www/wwwroot/wanily/core/server/web/parent-app.js:54:36)\n at /www/wwwroot/wanily/core/server/index.js:82:48\n at tryCatcher (/www/wwwroot/wanily/node_modules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFromHandler (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:512:31)\n at Promise._settlePromise (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:569:18)\n at Promise._settlePromise0 (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:614:10)\n at Promise._settlePromises (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:693:18)\n at Promise._fulfill (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:638:18)\n at PromiseArray._resolve (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise_array.js:126:19)\n at PromiseArray._promiseFulfilled (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise_array.js:144:14)\n at Promise._settlePromise (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:574:26)\n at Promise._settlePromise0 (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:614:10)\n at Promise._settlePromises (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:693:18)\n\nError: Cannot find module '/www/wwwroot/wanily/core/server/adapters/storage/ghost-oss-store'\n at Function.Module._resolveFilename (module.js:476:15)\n at Function.Module._load (module.js:424:25)\n at Module.require (module.js:504:17)\n at require (internal/module.js:20:19)\n at Object.getStorage (/www/wwwroot/wanily/core/server/adapters/storage/index.js:57:42)\n at setupSiteApp (/www/wwwroot/wanily/core/server/web/site/app.js:74:73)\n at setupParentApp (/www/wwwroot/wanily/core/server/web/parent-app.js:54:36)\n at /www/wwwroot/wanily/core/server/index.js:82:48\n at tryCatcher (/www/wwwroot/wanily/node_modules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFromHandler (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:512:31)\n at Promise._settlePromise (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:569:18)\n at Promise._settlePromise0 (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:614:10)\n at Promise._settlePromises (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:693:18)\n at Promise._fulfill (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise.js:638:18)\n at PromiseArray._resolve (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise_array.js:126:19)\n at PromiseArray._promiseFulfilled (/www/wwwroot/wanily/node_modules/bluebird/js/release/promise_array.js:144:14)"},"msg":"We detected a misuse. Please read the stack trace.","time":"2018-06-17T14:41:46.050Z","v":0}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.