Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add support for streaming in getPrivateUrl

  • Loading branch information...
commit 5c43318e8ab6f3c506edcfe81f9cbd7201f8ed37 1 parent b66820e
Christian Tellnes authored
Showing with 21 additions and 6 deletions.
  1. +21 −6 lib/index.js
27 lib/index.js
View
@@ -425,8 +425,6 @@ CloudFront.prototype.listOriginAccessIdentities = function(opts, cb) {
8) options
-
- Does not support streaming at the moment.
*/
CloudFront.prototype.getPrivateUrl = function(a, b, c, d) {
@@ -440,6 +438,7 @@ CloudFront.prototype.getPrivateUrl = function(a, b, c, d) {
config.hostname = obj.hostname;
config.path = obj.path;
config.secure = obj.protocol === 'https:';
+ config.streaming = obj.protocol === 'rtmp:';
}
// args 1 and 2
@@ -501,7 +500,7 @@ CloudFront.prototype.getPrivateUrl = function(a, b, c, d) {
throw new TypeError('Missing path argument to CloudFront#getPrivateUrl');
}
- var resource, policy, signature
+ var resource, policy, signature, scheme
, keyPairId = config.keyPairId || this.keyPairId
, privateKey = config.privateKey || this.privateKey
, custom = false
@@ -512,8 +511,18 @@ CloudFront.prototype.getPrivateUrl = function(a, b, c, d) {
}
+ if (config.hostname.substr(-'.cloudfront.net'.length) === '.cloudfront.net') {
+ // I can not find this documented, but AWS SDK for PHP does it in this way.
+ config.streaming = (config.hostname[0] === 's');
+ }
- resource = 'http' + (config.secure ? 's' : '') + '://' + config.hostname + config.path;
+ if (config.streaming) {
+ scheme = 'rtmp';
+ resource = config.path;
+ } else {
+ scheme = config.secure ? 'https' : 'http';
+ resource = scheme + '://' + config.hostname + config.path;
+ }
policy = {
"Statement": [{
@@ -557,8 +566,14 @@ CloudFront.prototype.getPrivateUrl = function(a, b, c, d) {
query["Expires"] = config.expires;
}
- resource += (~config.path.indexOf('?') ? '&' : '?') + querystring.stringify(query);
- return resource;
+ return scheme
+ + '://'
+ + config.hostname
+ + config.path
+ + (~config.path.indexOf('?') ? '&' : '?')
+ + querystring.stringify(query)
+ ;
+
};
Please sign in to comment.
Something went wrong with that request. Please try again.