From a3956ad05d3629769623f717b950fc86d908caf1 Mon Sep 17 00:00:00 2001 From: gsuess Date: Sun, 29 Mar 2015 14:35:23 +0200 Subject: [PATCH 1/2] Fixes #84 Do not use NPM path for processing http URLs. --- services/aws-s3.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/services/aws-s3.js b/services/aws-s3.js index 31c9286..082976f 100644 --- a/services/aws-s3.js +++ b/services/aws-s3.js @@ -20,14 +20,14 @@ Slingshot.S3Storage = { check(acl, String); return [ - "private", - "public-read", - "public-read-write", - "authenticated-read", - "bucket-owner-read", - "bucket-owner-full-control", - "log-delivery-write" - ].indexOf(acl) >= 0; + "private", + "public-read", + "public-read-write", + "authenticated-read", + "bucket-owner-read", + "bucket-owner-full-control", + "log-delivery-write" + ].indexOf(acl) >= 0; })), key: Match.OneOf(String, Function), @@ -74,8 +74,6 @@ 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)), @@ -98,24 +96,29 @@ Slingshot.S3Storage = { directive.bucketUrl(directive.bucket, directive.region) : directive.bucketUrl, - downloadPath = path.join((directive.cdn || bucketUrl), payload.key), - - download = url.parse(downloadPath); + downloadUrl = [ + (directive.cdn || bucketUrl), + payload.key + ].map(function (part) { + return part.replace(/\/+$/, ''); + }).join("/"); this.applySignature(payload, policy, directive); + console.log(downloadUrl); + return { upload: bucketUrl, - download: url.format(download), + download: downloadUrl, postData: [{ name: "key", value: payload.key }].concat(_.chain(payload).omit("key").map(function (value, name) { return !_.isUndefined(value) && { - name: name, - value: value - }; - }).compact().value()) + name: name, + value: value + }; + }).compact().value()) }; }, From 754c84d0db53f5c17c6ade4911ba5f73549924b2 Mon Sep 17 00:00:00 2001 From: gsuess Date: Sun, 29 Mar 2015 14:38:49 +0200 Subject: [PATCH 2/2] Fixes #84 - Bump version --- CHANGELOG.md | 5 +++++ package.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a06d54..b2cf91c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Slingshot Changelog =================== +## Version 0.6.1 + + * Fixed bad S3 download url generation where the download url would start with `https:/` instead of `https://`. ([#84](https://github.com/CulturalMe/meteor-slingshot/issues/84)) + + ## Version 0.6.0 ### Bug Fixes diff --git a/package.js b/package.js index 4d49c19..b69682d 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name: "edgee:slingshot", summary: "Directly post files to cloud storage services, such as AWS-S3.", - version: "0.6.0", + version: "0.6.1", git: "https://github.com/CulturalMe/meteor-slingshot" });