From 42e9cf135ef12e55c2a18917af533bd5720487a0 Mon Sep 17 00:00:00 2001 From: tzangms Date: Thu, 1 May 2014 01:36:37 +0800 Subject: [PATCH] Add custom domain support and choose to use https or not. --- README.md | 4 +++- index.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd23f84..ce94184 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,9 @@ In your ghost config.js file under "development" and "production" add accessKeyId: 'your aws access key id>', secretAccessKey: 'your AWS secret access key>', bucket: 'your-bucket-name', - region: 'the AWS region your bucket is in' + region: 'the AWS region your bucket is in', + customDomain: 'example.com', + isSecure: false }, diff --git a/index.js b/index.js index 2204335..2ecc3f1 100644 --- a/index.js +++ b/index.js @@ -33,7 +33,18 @@ module.exports.save = function(image) { var targetDir = getTargetDir(); var targetFilename = getTargetName(image, targetDir); - var awsPath = 'https://' + config.bucket + '.s3.amazonaws.com/'; + + if (config.isSecure) { + var protocol = 'https'; + } else { + var protocol = 'http'; + } + + if (config.customDomain) { + var awsPath = protocol + '://' + config.customDomain + '/'; + } else { + var awsPath = protocol + '://' + config.bucket + '.s3.amazonaws.com/'; + } return readFile(image.path) .then(function(buffer) {