Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Google Drive file storage as an option #182

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ If your Ghost app needs to support substantial traffic, then use a CDN add-on:

#### Using with file uploads disabled

Heroku app filesystems [aren’t meant for permanent storage](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem), so file uploads are disabled by default when using this repository to deploy a Ghost blog to Heroku. If you’re using Ghost on Heroku with S3 file uploads disabled, you should leave all environment variables beginning with `S3_…` blank.
Heroku app filesystems [aren’t meant for permanent storage](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem), so file uploads are disabled by default when using this repository to deploy a Ghost blog to Heroku. If you’re using Ghost on Heroku with AWS S3 or Google Drive file uploads disabled, you should leave all environment variables beginning with `S3_…` and `GOOGLE_DRIVE_…` blank.

#### Configuring S3 file uploads
#### Configuring AWS S3 file uploads

To configure S3 file storage, create an S3 bucket on Amazon AWS, and then specify the following details as environment variables on the Heroku deployment page (or add these environment variables to your app after deployment via the Heroku dashboard):

Expand All @@ -41,7 +41,7 @@ To configure S3 file storage, create an S3 bucket on Amazon AWS, and then specif

Once your app is up and running with these variables in place, you should be able to upload images via the Ghost interface and they’ll be stored in Amazon S3. :sparkles:

##### Provisioning an S3 bucket using an add-on
##### Provisioning an AWS S3 bucket using an add-on

If you’d prefer not to configure S3 manually, you can provision the [Bucketeer add-on](https://devcenter.heroku.com/articles/bucketeer)
to get an S3 bucket (Bucketeer starts at $5/mo).
Expand All @@ -58,6 +58,12 @@ heroku addons:create bucketeer --app YOURAPPNAME
heroku config:set S3_BUCKET_REGION=us-east-1 --app YOURAPPNAME
```

#### Configuring Google Drive file uploads

An alternative to S3 file storage is Google Drive file storage, which offers up to 15GB of free storage. To configure Google Drive storage, specify the following environment variables during app deployment, or in the app settings after the app is deployed.
- `GOOGLE_PRIVATE_KEY_ID`, `GOOGLE_PRIVATE_KEY`, `GOOGLE_CLIENT_EMAIL`, and `GOOGLE_CLIENT_ID`.
Instructions on how to obtain these variables can be found in the [ghost-google-drive](https://github.com/robincsamuel/ghost-google-drive) driver repository.

### How this works

This repository is a [Node.js](https://nodejs.org) web application that specifies [Ghost as a dependency](https://docs.ghost.org/v1.0.0/docs/using-ghost-as-an-npm-module), and makes a deploy button available.
Expand Down
16 changes: 16 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@
"S3_ASSET_HOST_URL": {
"description": "Optional custom CDN asset host url, if using S3 file storage.",
"required": false
},
"GOOGLE_PRIVATE_KEY_ID" : {
"description": "Set your Google Private Key ID to enable Google Drive file storage. Leave blank to disable file uploads.",
"required": false
},
"GOOGLE_PRIVATE_KEY": {
"description": "Google Drive Secret Key, if using Google Drive file storage.",
"required": false
},
"GOOGLE_CLIENT_EMAIL": {
"description": "Google Drive Cient Email, if using Google Drive file storage.",
"required": false
},
"GOOGLE_CLIENT_ID": {
"description": "Google Drive Client ID, if using Google Drive file storage.",
"required": false
}
}
}
15 changes: 14 additions & 1 deletion bin/create-config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@ var appRoot = path.join(__dirname, '..');
function createConfig() {
var fileStorage, storage;

if (!!process.env.S3_ACCESS_KEY_ID) {
if (!!process.env.GOOGLE_PRIVATE_KEY_ID) {
fileStorage = true
storage = {
active: 'ghost-google-drive',
'ghost-google-drive': {
key: {
private_key_id: process.env.GOOGLE_PRIVATE_KEY_ID,
private_key: process.env.GOOGLE_PRIVATE_KEY,
client_email: process.env.GOOGLE_CLIENT_EMAIL,
client_id: process.env.GOOGLE_CLIENT_ID
}
}
}
} else if (!!process.env.S3_ACCESS_KEY_ID) {
fileStorage = true
storage = {
active: 's3',
Expand Down
1 change: 1 addition & 0 deletions content/adapters/storage/ghost-google-drive
Loading