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) {