Skip to content

Commit

Permalink
Automattic#188 copyTo accepts object as a destination bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
kof committed Jul 12, 2013
1 parent 9129ba8 commit 4982329
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ Client.prototype.copyFile = function(sourceFilename, destFilename, headers, fn){
* with optional `headers`.
*
* @param {String} sourceFilename
* @param {String|Object} destBucket
* @param {String} destFilename
* @param {Object} headers
* @return {ClientRequest}
Expand All @@ -521,7 +522,11 @@ Client.prototype.copyFile = function(sourceFilename, destFilename, headers, fn){

Client.prototype.copyTo = function(sourceFilename, destBucket, destFilename, headers){
var options = utils.merge({}, this.options);
options.bucket = destBucket;
if (typeof destBucket == 'string') {
options.bucket = destBucket;
} else {
utils.merge(options, destBucket);
}
var client = exports.createClient(options);
return client.put(destFilename, getCopyHeaders(this.bucket, sourceFilename, headers));
};
Expand Down Expand Up @@ -793,7 +798,7 @@ Client.prototype.list = function(params, headers, fn){

var url = params ? '?' + qs.stringify(params) : '';

this.getFile(url, headers, function(err, res){
return this.getFile(url, headers, function(err, res){
if (err) return fn(err);

var xmlStr = '';
Expand Down

0 comments on commit 4982329

Please sign in to comment.