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

Add custom domain support and use http(s) or not #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
},


Expand Down
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option should be reversed (noHttps? useHttp?) so the default is still https://

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code is designed to use https, so I don't want to break it, so I just make isSecure option default false.

If someone upgrade to this plugin from original, they won't be break.

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