Skip to content

Commit

Permalink
Decode URI Components
Browse files Browse the repository at this point in the history
See #4
  • Loading branch information
wlaurance committed Jan 10, 2014
1 parent 94fb030 commit c4b221d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports.createClient = function(config){
}
}
Client.prototype.getFile = function(uri, headers, callback){
uri = decodeURIComponent(uri);
if (!callback && typeof(headers) == "function") {
callback = headers;
headers = {};
Expand Down Expand Up @@ -41,6 +42,8 @@ exports.createClient = function(config){
};

Client.prototype.putFile = function(from, to, callback){
from = decodeURIComponent(from);
to = decodeURIComponent(to);
function checkToPath(cb){
utils.checkToPath(config.bucket + to, cb);
}
Expand All @@ -63,6 +66,7 @@ exports.createClient = function(config){
});
};
Client.prototype.putBuffer = function(buffer, to, headers, callback){
to = decodeURIComponent(to);
utils.checkToPath(config.bucket + to, function(){
fs.writeFile(config.bucket + to, buffer, function(err){
if (err) {
Expand All @@ -73,6 +77,7 @@ exports.createClient = function(config){
});
};
Client.prototype.deleteFile = function(file, callback){
file = decodeURIComponent(file);
fs.unlink(config.bucket + file, function(err){
return callback(null, {headers:{}, statusCode: err ? 404 : 204});
});
Expand Down

0 comments on commit c4b221d

Please sign in to comment.