diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fae0b97 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +sudo: required +services: + - docker +language: node_js +node_js: + - "4.1" + - "4.0" + - "0.12" + - "0.11" + - "0.10" + - "0.8" + - "0.6" + - "iojs" +before_install: + - docker pull 66pix/s3ninja:latest +before_script: + - docker run -p "9444:9444" 66pix/s3ninja:latest & + - sleep 10 +addons: + hosts: + - node-s3-test.localhost + - s3-bucket.localhost diff --git a/lib/index.js b/lib/index.js index 01b188e..e3ccc47 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,6 +64,12 @@ function Client(options) { } } +Client.prototype.createBucket = function createBucket(bucket, cb) { + this.s3.createBucket({ + Bucket: bucket + }, cb); +} + Client.prototype.deleteObjects = function(s3Params) { var self = this; var ee = new EventEmitter(); @@ -102,7 +108,7 @@ Client.prototype.deleteObjects = function(s3Params) { cb(); } }); - }); + }); function tryDeletingObjects(cb) { self.s3Pend.go(function(pendCb) { @@ -466,7 +472,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); @@ -476,14 +482,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 { diff --git a/test/test.js b/test/test.js index 4b60b52..142bb5c 100644 --- a/test/test.js +++ b/test/test.js @@ -37,6 +37,7 @@ function createClient() { accessKeyId: process.env.S3_KEY, secretAccessKey: process.env.S3_SECRET, endpoint: process.env.S3_ENDPOINT, + sslEnabled: false }, }); } @@ -97,8 +98,7 @@ describe("s3", function () { Prefix: remoteRoot, Bucket: s3Bucket, }; - var deleter = client.deleteDir(s3Params); - deleter.on('end', function() { + client.createBucket(s3Bucket, function() { done(); }); });