1.0.6 • Published 10 years ago
ghost-storage v1.0.6
ghost-storage
Description
ghost-storage is a Ghost Blog plugin used to store static files in other cloud storage services like Amazon S3 instead of local file system storage.
Supported storage services
- Amazon S3 Storage
- Google Cloud Storage
Amazon S3 Storage
Configuration on AWS S3 console
- Generate Security Credentials in AWS console with
Access Key IDandSecret Access Key, credentials should be keep safe, otherwise can be used to access all AWS services by other users. - Create a bucket with a unique name and assign permission to yourself in order to upload, delete and view assets in bucket.
- Enable static site hosting and add policy below, so your bucket can be served as static site with read access to all users. For example, you can access your static files in browser with URL
example-bucket.s3-website-us-east-1.amazonaws.com
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::example-bucket/*"
]
}
]
}Setting up in Ghost Blog
In order to replace the storage module, the basic requirements are:
- Create a new folder inside
/contentcalled/storage - Inside of
/storageyou need to create your new module - Your
config.jsfile will need to be updated to provide config for your new storage module and set it as active.
- Get the name of bucket, subdomains of aws host path from AWS S3 console to update config file.
- In your
config.jsfile, you'll need to add a new storage block to whichever environment you want to change:
production: {
"others": {},
"storage": {
"active": "ghost-storage",
"ghost-storage": {
"accessKeyId": "",
"secretAccessKey": "",
"bucket": "example_bucket",
"awsPath": "s3-website-us-east-1.amazonaws.com"
}
},
}
development: {
}- Create
index.jsfile with folder pathcontent/storage/ghost-storage/index.js(manually create folder if not exist) and fill this file with content below
'use strict';
module.exports = require('ghost-storage').S3;Google Cloud Storage
Configuration on Google API console
- Generate Security Credentials in Google API console with
Project IDand downloadJSON keyfile, credentials should be keep safe. - Create a new bucket with domain unique name and make it public to be readable to all visitors. Write down
bucket nameto be used later.
Setting up in Ghost blog
- Repeat most steps as the same in Amazon S3 Storage configuration.
- Put
key.jsonfile under the same directory asconfig.jsto be imported in Ghost configuration. - Update your
config.jsfile, you'll need to add a new storage block to whichever environment you want to change:
production: {
"others": {},
"storage": {
"active": "ghost-storage",
"ghost-storage": {
projectId: '',
keyFilename: path.join(__dirname, './key.json'),
bucket: 'bucket name',
gcloudPath: 'storage.googleapis.com'
}
},
}
development: {
}- Create
index.jsfile with folder pathcontent/storage/ghost-storage/index.js(manually create folder if not exist) and fill this file with content below.
'use strict';
module.exports = require('ghost-storage').Google;Collaboration
If you are interested in this project and want to be collaborators to implement other cloud storage plugins, please send pull requests or shoot me a email.