From f4369db0a926eb5a444ae30dd2df5a42386fee69 Mon Sep 17 00:00:00 2001 From: tgremi Date: Tue, 26 Sep 2017 17:50:25 -0300 Subject: [PATCH 1/2] changes --- index.js | 30 +++++++++++++++++++++++++++--- package.json | 13 ++++++------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 821a1e8..17ac5c9 100644 --- a/index.js +++ b/index.js @@ -43,12 +43,36 @@ module.exports = function SwiftStore(globalOpts) { objectMode: true }); + function __uuidGenerate(){ + this.length = 8; + this.timestamp = +new Date; + var _getRandomInt = function (min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } + + var ts = this.timestamp.toString(); + var parts = ts.split("").reverse(); + var id = ""; + + for (var i = 0; i < this.length; ++i) { + var index = _getRandomInt(0, parts.length - 1); + id += parts[index]; + } + return id; + } + + var uuid = __uuidGenerate() + receiver._write = function onFile(__newFile, encoding, done) { + var newFilename = __newFile + + newFilename.filename = uuid + newFilename.filename + var client = getClient(options.credentials); - console.log("Uploading file with name", __newFile.filename); + console.log("Uploading file with name", newFilename.filename); __newFile.pipe(client.upload({ container: options.container, - remote: __newFile.filename + remote: newFilename.filename }, function(err, value) { console.log(err); console.log(value); @@ -61,7 +85,7 @@ module.exports = function SwiftStore(globalOpts) { })); __newFile.on("end", function(err, value) { - console.log("finished uploading", __newFile.filename); + console.log("finished uploading", __newFile.fd); receiver.emit('finish', err, value ); done(); }); diff --git a/package.json b/package.json index 54ba75e..cfd3834 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "skipper-openstack", + "name": "skipper-openstack-gremi", "version": "0.0.1", "dependencies": { "pkgcloud": "git+https://github.com/IBM-Bluemix/pkgcloud.git#fix-openstack-auth", @@ -8,8 +8,7 @@ }, "main": "index.js", "repository": { - "type": "git", - "url": "https://github.com/IBM-Bluemix/skipper-openstack.git" + "type": "git" }, "keywords": [ "openstack-swift", @@ -24,13 +23,13 @@ ], "author": [ { - "name": "Jeff Sloyer", - "email": "jbsloyer@us.ibm.com" + "name": "Thalles Gremi", + "email": "thallesgremi@gmail.com" } ], "license": "Apache License V2", "bugs": { - "url": "https://github.com/IBM-Bluemix/skipper-openstack/issues" + "url": "https://github.com/tgremi/skipper-openstack/issues" }, - "homepage": "https://github.com/IBM-Bluemix/skipper-openstack" + "homepage": "https://github.com/tgremi/skipper-openstack" } From 267d46a0a742a6387e49d66a0a0b356cf247873c Mon Sep 17 00:00:00 2001 From: tgremi Date: Wed, 27 Sep 2017 00:31:11 -0300 Subject: [PATCH 2/2] changes --- index.js | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/index.js b/index.js index 17ac5c9..d7def8a 100644 --- a/index.js +++ b/index.js @@ -43,36 +43,12 @@ module.exports = function SwiftStore(globalOpts) { objectMode: true }); - function __uuidGenerate(){ - this.length = 8; - this.timestamp = +new Date; - var _getRandomInt = function (min, max) { - return Math.floor(Math.random() * (max - min + 1)) + min; - } - - var ts = this.timestamp.toString(); - var parts = ts.split("").reverse(); - var id = ""; - - for (var i = 0; i < this.length; ++i) { - var index = _getRandomInt(0, parts.length - 1); - id += parts[index]; - } - return id; - } - - var uuid = __uuidGenerate() - receiver._write = function onFile(__newFile, encoding, done) { - var newFilename = __newFile - - newFilename.filename = uuid + newFilename.filename - var client = getClient(options.credentials); - console.log("Uploading file with name", newFilename.filename); + console.log("Uploading file with name", __newFile.fd); __newFile.pipe(client.upload({ container: options.container, - remote: newFilename.filename + remote: __newFile.fd }, function(err, value) { console.log(err); console.log(value);