From b1ccb080ce25025087d30946236e692cc58099d7 Mon Sep 17 00:00:00 2001 From: dooart Date: Mon, 16 Mar 2015 00:05:52 -0300 Subject: [PATCH 1/3] fix for issue #73 --- services/aws-s3.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/aws-s3.js b/services/aws-s3.js index 77f5d2c..31c9286 100644 --- a/services/aws-s3.js +++ b/services/aws-s3.js @@ -47,10 +47,14 @@ Slingshot.S3Storage = { .extend({ bucket: Meteor.settings.S3Bucket, bucketUrl: function (bucket, region) { + var bucketDomain = "s3-" + region + ".amazonaws.com"; if (region === "us-east-1") - return "https://" + bucket + ".s3.amazonaws.com"; + bucketDomain = "s3.amazonaws.com"; - return "https://" + bucket + ".s3-" + region + ".amazonaws.com"; + if (bucket.indexOf(".") !== -1) + return "https://" + bucketDomain + "/" + bucket; + + return "https://" + bucket + "." + bucketDomain; }, region: Meteor.settings.AWSRegion || "us-east-1", expire: 5 * 60 * 1000 //in 5 minutes @@ -70,6 +74,8 @@ Slingshot.S3Storage = { upload: function (method, directive, file, meta) { var url = Npm.require("url"), + path = Npm.require("path"), + policy = new Slingshot.StoragePolicy() .expireIn(directive.expire) .contentLength(0, Math.min(file.size, directive.maxSize || Infinity)), @@ -92,9 +98,9 @@ Slingshot.S3Storage = { directive.bucketUrl(directive.bucket, directive.region) : directive.bucketUrl, - download = _.extend(url.parse(directive.cdn || bucketUrl), { - pathname: payload.key - }); + downloadPath = path.join((directive.cdn || bucketUrl), payload.key), + + download = url.parse(downloadPath); this.applySignature(payload, policy, directive); From 85daeddbc927204fb9a485fb30b651f397f1bbff Mon Sep 17 00:00:00 2001 From: gsuess Date: Sun, 22 Mar 2015 19:15:13 +0100 Subject: [PATCH 2/3] #65 Meteor.userId() is only available when accounts-base package is enabled --- lib/upload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/upload.js b/lib/upload.js index 9edde12..403941c 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -67,7 +67,7 @@ Slingshot.Upload = function (directive, metaData) { validate: function(file) { var context = { - userId: Meteor.userId() + userId: Meteor.userId && Meteor.userId() }; try { var validators = Slingshot.Validators, From 6ad9a19b463e5abbca2be7fe890a69ab858dbc3d Mon Sep 17 00:00:00 2001 From: gsuess Date: Sun, 22 Mar 2015 20:07:58 +0100 Subject: [PATCH 3/3] Updated changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9db0ff6..223212f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ Slingshot Changelog =================== +## Version 0.5.0 + +### Bug Fixes + + * Fixed error when `accounts-base` is not enabled. (([#65](https://github.com/CulturalMe/meteor-slingshot/issues/65) + +### Enhancements + + * Allow SSL to work for when bucket name contains a dot. + ## Version 0.4.1 ### Bug Fixes