Permalink
Browse files

Support subdirectories in containers

  • Loading branch information...
1 parent 0559b21 commit d431e309b8a7dad2a2fdddf7a74337864ba759f3 @davidbanham committed Aug 10, 2012
Showing with 11 additions and 1 deletion.
  1. +7 −1 lib/cloudfiles/core.js
  2. +4 −0 lib/cloudfiles/storage-object.js
@@ -318,11 +318,17 @@ Cloudfiles.prototype.getFiles = function (container, marker, download, callback)
Cloudfiles.prototype.getFile = function (container, filename, callback) {
var self = this,
+ parts = filename.split('/'),
containerPath = path.join(this.config.cache.path, container),
cacheFile = path.join(containerPath, filename),
options;
+
+ parts.pop();
+ var subPath = parts.join('/');
+
+ if(subPath === '') common.statOrMkdirp(containerPath);
+ else common.statOrMkdirp(containerPath+'/'+subPath);
- common.statOrMkdirp(containerPath);
var lstream = fs.createWriteStream(cacheFile),
rstream,
@@ -88,6 +88,10 @@ StorageObject.prototype = {
save: function (options, callback) {
var self = this;
+ var path = options.local.split('/');
+ path.pop();
+ path = path.join('/');
+ common.statOrMkdirp(path);
var fileStream = fs.createWriteStream(options.local, {
flags: options.flags || 'w+',
encoding: options.encoding || null,

0 comments on commit d431e30

Please sign in to comment.