From ab041c63ea2e1d81e17f33eaf00788d4bebe76c0 Mon Sep 17 00:00:00 2001 From: Robin Qu Date: Wed, 29 Aug 2012 18:41:29 +0800 Subject: [PATCH 1/2] encode uri to support utf8 chars --- lib/cloudfiles/core.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cloudfiles/core.js b/lib/cloudfiles/core.js index 524ad3a..161230f 100644 --- a/lib/cloudfiles/core.js +++ b/lib/cloudfiles/core.js @@ -414,9 +414,11 @@ Cloudfiles.prototype.destroyFile = function (container, file, callback) { // Cloudfiles.prototype.storageUrl = function () { var args = Array.prototype.slice.call(arguments), - json = (typeof(args[args.length - 1]) === 'boolean') && args.pop(); + json = (typeof(args[args.length - 1]) === 'boolean') && args.pop(), + pathname; - return [this.config.storageUrl].concat(args).join('/') + (json ? '?format=json' : ''); + pathname = '/' + encodeURI(args.join('/') + (json ? '?format=json' : '')); + return this.config.storageUrl + pathname; }; // @@ -427,7 +429,9 @@ Cloudfiles.prototype.storageUrl = function () { // Cloudfiles.prototype.cdnUrl = function () { var args = Array.prototype.slice.call(arguments), - json = (typeof(args[args.length - 1]) === 'boolean') && args.pop(); + json = (typeof(args[args.length - 1]) === 'boolean') && args.pop(), + pathname; - return [this.config.cdnUrl].concat(args).join('/') + (json ? '?format=json' : ''); + pathname = '/' + encodeURI(args.join('/') + (json ? '?format=json' : '')); + return this.config.cdnUrl + pathname; }; From 69465c5e3b3045eacc8c772e8c868320457b6ae7 Mon Sep 17 00:00:00 2001 From: Robin Qu Date: Mon, 10 Sep 2012 13:44:40 +0800 Subject: [PATCH 2/2] stream file --- lib/cloudfiles/core.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/cloudfiles/core.js b/lib/cloudfiles/core.js index 161230f..b759046 100644 --- a/lib/cloudfiles/core.js +++ b/lib/cloudfiles/core.js @@ -343,6 +343,27 @@ Cloudfiles.prototype.getFile = function (container, filename, callback) { }); }; +Cloudfiles.prototype.streamFile = function(container, filename, lstream, callback) { + var self = this, + containerPath = path.join(this.config.cache.path, container), + cacheFile = path.join(containerPath, filename), + options; + common.statOrMkdirp(containerPath); + + var rstream, + options; + + options = { + method: 'GET', + client: self, + uri: self.storageUrl(container, filename), + download: lstream + }; + + rstream = common.rackspace(options, callback); +}; + + // // options // remote