ghost-v3-google-cloud-storage
Advanced tools
Comparing version 1.3.0 to 1.4.0
{ | ||
"name": "ghost-v3-google-cloud-storage", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "A Google Cloud Storage adapter for Ghost v3 (www.ghost.org).", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -20,4 +20,4 @@ # Ghost v3 Google Cloud Storage Adapter | ||
# Copy the GCS storage adapter to the correct location so Ghost can find it | ||
cp -R node_modules/ghost-v3-google-cloud-storage/* content/adapters/storage/gcs/ | ||
# Move the GCS storage adapter to the correct location so Ghost can find it | ||
mv node_modules/ghost-v3-google-cloud-storage/* content/adapters/storage/gcs/ | ||
``` | ||
@@ -46,2 +46,8 @@ | ||
} | ||
``` | ||
``` | ||
**bucket**: Required. | ||
**keyFilename**: Optional if Ghost is hosted on GCP. | ||
**cdn**: Optional. If you use a CDN, this is the CDN base URL. |
@@ -71,3 +71,9 @@ 'use strict'; | ||
read(options = {}) { | ||
const readStream = this.bucket.file(options.path).createReadStream() | ||
const prefix = `https://${this.assetDomain}/` | ||
let path = options.path | ||
if (path.indexOf(prefix) === 0) { | ||
path = path.slice(prefix.length); | ||
} | ||
const readStream = this.bucket.file(path).createReadStream() | ||
let contents = null; | ||
@@ -80,9 +86,9 @@ return new Promise(function(resolve, reject) { | ||
if (contents) { | ||
contents = Buffer.concat([contents, data]); | ||
} else { | ||
contents = data; | ||
} else { | ||
contents = Buffer.concat([contents, data]); | ||
} | ||
}); | ||
readStream.on('end', function() { | ||
return resolve(content); | ||
return resolve(contents); | ||
}); | ||
@@ -89,0 +95,0 @@ }); |
5381
4
83
51