Comparing version 1.0.1 to 1.0.2
@@ -11,2 +11,4 @@ /** | ||
var os = require('os'), | ||
path = require('path'), | ||
fs = require('fs'), | ||
exec = require('child_process').exec, | ||
@@ -16,7 +18,7 @@ cloudpt = require('NodeCloudPT')(config); | ||
var run = function() { | ||
var options = {path: '/cloudify', list: false}; | ||
var options = { path: '/cloudify', list: false }; | ||
cloudpt.metadata(options, function(data) { | ||
// we dont support directories, for now | ||
if (data && data.is_dir === false) { | ||
cloudpt.createFolder({path: '/cloudify'}, upload); | ||
cloudpt.createFolder({ path: '/cloudify' }, upload); | ||
} else { | ||
@@ -29,3 +31,11 @@ upload(); | ||
var upload = function() { | ||
var options = {path: '/cloudify/' + filename, file: filename}; | ||
var options = { | ||
path: '/cloudify/' + path.basename(filename), | ||
file: filename | ||
}; | ||
var fileStats = fs.statSync(filename); | ||
var fileSize = getPrettyFileSize(fileStats.size); | ||
console.log('Uploading (' + fileSize +') ...'); | ||
cloudpt.upload(options, function(data) { | ||
@@ -37,3 +47,3 @@ if (data) { getPublicLink(); } | ||
var getPublicLink = function() { | ||
var options = {path: '/cloudify/' + filename}; | ||
var options = { path: '/cloudify/' + path.basename(filename) }; | ||
cloudpt.shares(options, function(data) { | ||
@@ -51,4 +61,7 @@ var data = JSON.parse(data); | ||
exec('echo "' + str + '"|pbcopy', function(err) { | ||
if (err) { | ||
console.log(err); | ||
process.exit(1); | ||
} | ||
console.log('Saved to clipboard!'); | ||
if (err) { console.log(err); } | ||
process.exit(0); // hack to avoid http timeout | ||
@@ -61,3 +74,14 @@ }); | ||
var getPrettyFileSize = function(size) { | ||
var sizeUnit = 'kB'; | ||
var fileSize = (size / 1024); | ||
if (fileSize > 1024) { | ||
fileSize = fileSize / 1024; | ||
sizeUnit = 'MB'; | ||
} | ||
// round to two decimals | ||
return (Math.round(fileSize * 100) / 100) + ' ' + sizeUnit; | ||
}; | ||
return run; | ||
}; |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"repository": { | ||
@@ -12,0 +12,0 @@ "type": "git", |
@@ -13,4 +13,6 @@ # Cloudify - Share your files from the command line | ||
After you will have to run cloudify one first time, and it will create the configuration file for you. Then edit the file `~/.cloudifyrc` and complete with OAuth stuff (access token). | ||
When you first run `cloudify`, the CloudPT OAuth setup will take place. Just follow the instructions to enable access to your account. | ||
After the setup your OAuth tokens will be stored in a file at `~/.cloudifyrc`. | ||
## Usage | ||
@@ -17,0 +19,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9372
162
26
3