From cb98926429aca0e67a940e8d5f8f379ac3db060c Mon Sep 17 00:00:00 2001 From: Benjamin Eidelman Date: Thu, 21 Jan 2016 19:40:02 -0300 Subject: [PATCH] allow Key override at getS3Params() --- lib/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index e06e0fc..b1c1ba8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -460,7 +460,7 @@ Client.prototype.downloadFile = function(params) { if (statusCode >= 300) { handleError(new Error("http status code " + statusCode)); return; - } + } if (headers['content-length'] == undefined) { var outStream = fs.createWriteStream(localFile); outStream.on('error', handleError); @@ -470,14 +470,14 @@ Client.prototype.downloadFile = function(params) { downloader.progressTotal += chunk.length; downloader.progressAmount += chunk.length; downloader.emit('progress'); - outStream.write(chunk); + outStream.write(chunk); }) - request.on('httpDone', function() { + request.on('httpDone', function() { if (errorOccurred) return; downloader.progressAmount += 1; downloader.emit('progress'); - outStream.end(); + outStream.end(); cb(); }) } else { @@ -1169,7 +1169,9 @@ function syncDir(self, params, directionIsToS3) { function startUpload() { ee.progressTotal += localFileStat.size; var fullKey = prefix + localFileStat.s3Path; - upDownFileParams.s3Params.Key = fullKey; + if (!upDownFileParams.s3Params.Key) { + upDownFileParams.s3Params.Key = fullKey; + } upDownFileParams.localFile = fullPath; var uploader = self.uploadFile(upDownFileParams); var prevAmountDone = 0;