Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baidubce-cli

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baidubce-cli - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

4

package.json
{
"name": "baidubce-cli",
"version": "0.0.8",
"version": "0.0.9",
"description": "baidu cloud engine command line tools",

@@ -31,4 +31,6 @@ "main": "index.js",

"dependencies": {
"async": "^1.4.2",
"baidubce-sdk": "^0.0.16",
"debug": "^2.1.3",
"glob": "^5.0.14",
"humanize": "0.0.9",

@@ -35,0 +37,0 @@ "moment": "^2.8.4",

@@ -50,2 +50,5 @@ /**

.options('put-dir', {describe: 'Upload a directory', requiresArg: true})
.example('baidubce bos --put-dir my-dir bos://my-bucket/', 'Upload a directory')
.options('copy-object', {describe: 'Copy object from one bucket to another', 'boolean': true})

@@ -116,4 +119,5 @@ .example('baidubce bos --copy-object bos://source/sk.js bos://target/tk.js <options>',

'delete-buckets': deleteBuckets,
'copy-object': copyObject
'copy-object': copyObject,
};
for (var ak in actionMap) {

@@ -125,3 +129,3 @@ if (args[ak] === true) {

if (args['put-object'] || args['put-superfile']) {
if (args['put-dir'] || args['put-object'] || args['put-superfile']) {
var destination = args._[0];

@@ -139,3 +143,6 @@ var match = kPattern.exec(destination);

if (args['put-object']) {
if (args['put-dir']) {
return cmdPut.uploadDirectory(client, bucket_name, key, args['put-dir']);
}
else if (args['put-object']) {
return cmdPut.putRegularFile(client, bucket_name, key, args['put-object']);

@@ -334,6 +341,3 @@ }

// 2. then check the -p or -s argument value the first step failed.
var basename = path.basename(args['put-object'] || args['put-superfile']);
if (!basename) {
throw new Error('Invalid argument, can not find the object name');
}
var basename = path.basename(args['put-object'] || args['put-superfile'] || '');

@@ -340,0 +344,0 @@ // 3. If the key end with slash, so it's directory, we need append the basename

@@ -17,8 +17,55 @@ /**

var u = require('underscore');
var glob = require('glob');
var async = require('async');
var Q = require('q');
var debug = require('debug')('cmd_put');
exports.uploadDirectory = function (client, bucket_name, key, directory) {
debug('bucket_name = %j, key = %j, directory = %j',
bucket_name, key, directory);
var stat = fs.lstatSync(directory);
if (!stat.isDirectory()) {
throw new Error('Invalid file type');
}
var failedItems = [];
function iterator(item, callback) {
var objectKey = key ? (key + item) : item;
client.putObjectFromFile(bucket_name, objectKey, item)
.then(function () {
console.log('[DONE]:%s => bos://%s/%s',
item, bucket_name, objectKey);
})
.catch(function (error) {
console.error(error);
failedItems.push(item);
})
.fin(callback);
}
function done() {
if (failedItems.length) {
console.log('\n -- FAILED ITEMS --');
console.log(failedItems.join('\n'));
}
else {
console.log('All goes well.');
}
}
glob('**/*', {nodir: true, cwd: directory}, function (er, files) {
async.eachLimit(files, 2, iterator, done);
});
};
exports.putRegularFile = function (client, bucket_name, key, filename) {
debug('putRegularFile bucket_name = %j, key = %j, filename = %j',
bucket_name, key, filename);
var stat = fs.lstatSync(filename);
if (!stat.isFile()) {
throw new Error('Invalid file type');
}
client.putObjectFromFile(bucket_name, key, filename)

@@ -34,2 +81,7 @@ .then(function () {

exports.putSuperLargeFile = function (client, bucket_name, key, filename) {
var stat = fs.lstatSync(filename);
if (!stat.isFile()) {
throw new Error('Invalid file type');
}
var upload_id = null;

@@ -36,0 +88,0 @@ client.initiateMultipartUpload(bucket_name, key)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc