Skip to content

Commit

Permalink
Merge pull request #79 from CulturalMe/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
gsuess committed Mar 22, 2015
2 parents 4c36d27 + 6ad9a19 commit b7d9a6f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 11 additions & 5 deletions services/aws-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)),
Expand All @@ -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);

Expand Down

0 comments on commit b7d9a6f

Please sign in to comment.