Code Monkey home page Code Monkey logo

ghost-s3-compat's Introduction

Ghost S3 Storage, compatability mode

This module allows you to read and write images from Amazon S3 instead of storing them locally.

After installing, new images that you save will use an absolute URL to S3. Any requests to /content/images/ will be proxied to S3, so that any previous images in your blog will not be affected.

Installation

You will need to have a the custom storage module directly in your project directory, the easiest way to do this is:

$ npm install ghost-s3-compat
$ mkdir content/storage
$ cp -r node_modules/ghost-s3-compat content/storage/ghost-s3-compat

Configuration

Create new IAM User with permissions to get object from that bucket. Save the ACCESS_KEY and ACCESS_SECRET_KEY.

In config.js, add a storage block for each environment.

    storage: {
        active: 'ghost-s3',
        'ghost-s3': {
            accessKeyId: 'Put_your_access_key_here',
            secretAccessKey: 'Put_your_secret_key_here',
            bucket: 'Put_your_bucket_name_here',
            region: 'Put_your_bucket_region_here'
        }
    },

Asset host

You can add assetHost to your config to specify a virtual host url. This is most frequently used with a content delivery network (CDN) such as CloudFront, CloudFlare, or others. The modified storage block would be:

    storage: {
        active: 'ghost-s3',
        'ghost-s3': {
            accessKeyId: 'ACCESS_KEY',
            secretAccessKey: 'SECRET_ACCESS_KEY',
            bucket: 'S3_BUCKET_NAME',
            region: 'S3_REGION',
            assetHost: 'https://cdn.yourdomain.com/'
        }
    }

You can add assetHost to your config to specify a virtual host url. For more information, read this section in the AWS docs.

Copyright & License

  • Original work Copyright (c) 2015 Hoang Pham Huu [email protected]
  • Modified work Copyright (c) 2016 Curiosity Media, Inc.

Released under the MIT license.

ghost-s3-compat's People

Contributors

muzix avatar juancaicedo avatar glenashley avatar jrichocean avatar garu avatar joeyespo avatar aboutte avatar acburdine avatar nsfmc avatar

Stargazers

 avatar Andrew Shebanow avatar Eliza Minelli avatar Salaheddin AbuEin avatar Philip Okugbe avatar Samuel Clements avatar  avatar Mark Stosberg avatar Jan Bílek avatar Sugeng Tigefa avatar disinfeqt avatar Yovko Lambrev avatar Christopher Parker avatar Emmanoel Coutinho avatar Ibrahim Cesar avatar Fabián Arias avatar Diligent Marketing Solutions avatar Ivan Carosati avatar Javier Gómez Rodríguez avatar Omer Lahav avatar Steven Kessler avatar Armel Soro avatar igorrmotta avatar Ikbel avatar Dmitriy Belyaev avatar Vivien Giraud avatar alireza faghani avatar Parker avatar Stanislas avatar  avatar Onofre Souza avatar dßDaryl avatar Fabian B. avatar Raghd Hamzeh avatar Abhishek Tiwari avatar Victor Truong avatar k0nsl avatar William Hollacsek avatar Isaac Gaskin avatar Konstantin Portnov avatar Huiren Woo avatar  avatar Daniel Dương avatar Steven Hsu avatar Christoph Voigt avatar Colin Meinke avatar LEE Jaeyoung avatar Daegwon Nacyot Kim avatar Juan Carlos Christensen avatar Antal Orcsik avatar Pascal Andy avatar Mattia Natali avatar Cyrille David avatar Gary Lai avatar Christopher Vachon avatar

Watchers

Kenan Shifflett avatar William Bert avatar James Cloos avatar Meg Dzeng avatar Ben Fonarov avatar Russell avatar  avatar Suzanne Ohlhausen avatar  avatar Sean Karson avatar  avatar

ghost-s3-compat's Issues

Connot find module ghost-s3

Hey,

I got the issue, that it was not able to find the storage module, when I followed your installation steps:

ERROR: Cannot find module '/home/cv/nodejs/ghost/content/storage/ghost-s3'

 Error: Cannot find module '/home/cv/nodejs/ghost/content/storage/ghost-s3'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.getStorage (/home/cv/nodejs/ghost/core/server/storage/index.js:19:34)
    at setupMiddleware (/home/cv/nodejs/ghost/core/server/middleware/index.js:124:44)
    at /home/cv/nodejs/ghost/core/server/index.js:130:9
    at tryCatcher (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromise0 (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:685:18)
    at Promise._fulfill (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:630:18)
    at PromiseArray._resolve (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise_array.js:125:19)
    at PromiseArray._promiseFulfilled (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise_array.js:143:14)
    at Promise._settlePromise (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:566:26)
    at Promise._settlePromise0 (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:685:18)
    at Async._drainQueue (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)


ERROR: storage[storageChoice] is not a function

 TypeError: storage[storageChoice] is not a function
    at Object.getStorage (/home/cv/nodejs/ghost/core/server/storage/index.js:25:30)
    at setupMiddleware (/home/cv/nodejs/ghost/core/server/middleware/index.js:124:44)
    at /home/cv/nodejs/ghost/core/server/index.js:130:9
    at tryCatcher (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromise0 (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:685:18)
    at Promise._fulfill (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:630:18)
    at PromiseArray._resolve (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise_array.js:125:19)
    at PromiseArray._promiseFulfilled (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise_array.js:143:14)
    at Promise._settlePromise (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:566:26)
    at Promise._settlePromise0 (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:606:10)


    at Promise._settlePromises (/home/cv/nodejs/ghost/node_modules/bluebird/js/release/promise.js:685:18)

I was able to fix it by doing

$ cp -r node_modules/ghost-s3-compat content/storage/ghost-s3

instead of

$ cp -r node_modules/ghost-s3-compat content/storage/ghost-s3-compat

Sorry - I'm a little on the rush, so no further investigation - probably the module name can be defined somewhere (maybe in config.js active: ghost-s3?).

Please correct the install instructions

Hi there!

I have just done a review of all the modules that have been linked here.

Your install instructions require users to do an npm install --save - this modifies the package.json and makes the upgrade path for Ghost much, much harder. This was never the intention with the storage system.

Instead of npm install --save, please update your README and advise people to do the following:

mkdir content/storage (make the storage folder if it doesn't exist yet)
cp node_modules/<module_name> content/storage/<module_name> (copy the module into the right location)

That makes it much easier to upgrade Ghost in future.

We are in the process of adding a cli tool that will do these steps automatically, so if your module isn't setup to work this way, it will need to be very soon 😉

Remove redundancy install

$ npm install ghost-s3-compat
$ mkdir content/storage
$ cp -r node_modules/ghost-s3-compat content/storage/ghost-s3-compat

This seems like it's harder then necessary to maintain.

I'm using this solution, are there any downsides to this compared to the one above?

$ npm install ghost-s3-compat
$ mkdir content/storage
$ mkdir content/storage/ghost-s3
$ echo module.exports = require('ghost-s3-compat') > content/storage/ghost-s3/index.js

Remove methods from prototype.

Looking at this, I don't think there's any need for the storage module to export an actual class, so it should be possible to remove the save and serve methods from the prototype. That should make the code a lot easier to read.

Ignores existing bucket policy while setting images to public.

I have been using a manual upload process prior to finding this awesome add-on and my bucket policies are set to prevent hotlinking and restrict access to a specific HTTP referrer.

However, after getting this to work (newest ghost version), I noticed it uploads files with with public Everyone permissions while ignoring my bucket policies somehow. Is there any way to fix this or give some guidance on how to override & manually rely on my bucket policies? I have confirmed that when I manually upload via the web portal, Cyberduck, etc to /bucket/2017/01/ that my bucket policy is working correctly but creating a new blog post and the app uploads it to the same folder, the new image is given everyone completely public permissions.

Thanks for the great app & your time!

this worked.

Thank you. I tried a couple of the other ghost-s3 configs without luck. The only glitch I came across was on the S3 side. S3 reports the "region" as "Oregon" so I tried that even though it seemed wrong. Once I changed it to "us-west-2" in config.js all was good.

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.