Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
emitter.on('end', function() {
// console.log('Entire directory has been walked.');
fmt.field('WalkingDir', 'Finished');
});
});
var accessKeyId = env.ACCESS_KEY_ID;
var secretAccessKey = env.SECRET_ACCESS_KEY;
var awsAccountId = env.AWS_ACCOUNT_ID;
var sts = new Sts({
'accessKeyId' : accessKeyId,
'secretAccessKey' : secretAccessKey,
// 'awsAccountId' : awsAccountId, // optional
'region' : amazon.US_EAST_1
});
fmt.field('Region', sts.region() );
fmt.field('EndPoint', sts.host() );
fmt.field('AccessKeyId', sts.accessKeyId().substr(0, 3) + '...' );
fmt.field('SecretAccessKey', sts.secretAccessKey().substr(0, 3) + '...' );
fmt.field('AwsAccountId', sts.awsAccountId() );
sts.GetSessionToken(function(err, data) {
fmt.msg("gettting a session token - expecting success");
fmt.dump(err, 'Error');
fmt.dump(data, 'Data');
});
function doRequest(marker) {
var options = {
BucketName : bucketname,
};
if ( marker ) {
options.Marker = marker;
}
fmt.field('Request', options.Marker || '[start]');
s3.ListObjects(options, function(err, data) {
if (err) {
callback(err, null);
return;
}
fmt.field('Items', data.Body.ListBucketResult.Contents.length);
// loop through all the items and add them on to our saved list
data.Body.ListBucketResult.Contents.forEach(function(v, i) {
// ignore all .dotfiles
if ( v.Key.substr(0, 1) === '.' ) {
fmt.field('IgnoringDotObject', v.Key);
return;
}
fs.stat(item.filename, function(err, stats) {
if ( err ) {
// this file doesn't exist so we can't upload it
fmt.field('FileNotExist', item.filename);
callback();
return;
}
// we know there is a file
item.size = stats.size;
// add it to the upload queue
uploadItemQueue.push(item);
callback();
});
}
data.Body.ListBucketResult.Contents.forEach(function(v, i) {
// ignore all .dotfiles
if ( v.Key.substr(0, 1) === '.' ) {
fmt.field('IgnoringDotObject', v.Key);
return;
}
// remove the extra "" around the MD5
v.ETag = v.ETag.substr(1, 32);
// convert the size to a number
v.Size = parseInt(v.Size, 10);
// now push onto the array
items.push(v);
});
objects.forEach(function(item, i) {
// ignore any keys that look like directories (the ones that the Amazon AWS Console creates)
if ( item.Size === 0 && item.Key.charAt(item.Key.length-1) === '/' ) {
fmt.field('IgnoringDirKey', item.Key);
return;
}
checkItemIsLocalQueue.push(item);
});
sts.GetSessionToken(function(err, data) {
fmt.msg("gettting a session token - expecting success");
fmt.dump(err, 'Error');
fmt.dump(data, 'Data');
});
s3.GetObjectMetadata(options, function(err, data) {
fmt.msg("getting an object from pie-18 - expecting success");
fmt.dump(err, 'Error');
fmt.dump(data, 'Data');
});
sqs.AddPermission(options, function(err, data) {
fmt.msg("Adding a set of Policies to this queue - expecting failure (for many reasons)");
fmt.dump(err, 'Error');
fmt.dump(data, 'Data');
});
s3.CompleteMultipartUpload(options, function(err, data) {
fmt.msg("completing upload - expecting failure (no such upload)");
fmt.dump(err, 'Error');
fmt.dump(data, 'Data');
});