let s3 = require('s3');
//Format HttpUploadProgress Size
function formatBytes(a, b) {
if (0 == a) return "0 Bytes";
let c = 1024,
d = b || 2,
e = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
f = Math.floor(Math.log(a) / Math.log(c));
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
}
let client = s3.createClient({
s3RetryCount: 3, // this is the default
s3RetryDelay: 1000, // this is the default
multipartUploadSize: 5242880, // this is the default (15 MB)
s3Options: {
accessKeyId: "blahblah",
secretAccessKey: "blahblah",
region:"us-gov-west-1"
},
});
let params = {
localDir: "/home/ec2-user/sync/",
deleteRemoved: true, // default false, whether to remove s3 objects
// that have no corresponding local file.
s3Params: {
Bucket: "ami-bucket-govcloud",
// other options supported by putObject, except Body and ContentLength.
// See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property
},
};
let uploader = client.uploadDir(params);
uploader.on('error', function(err) {
console.error("unable to sync:", err.stack);
});
uploader.on('progress', function() {
console.log("progress", formatBytes(uploader.progressAmount), formatBytes(uploader.progressTotal));
});
uploader.on('end', function() {
console.log("done uploading");
});
The second which may be causing the issue, is the multipart sizes are not responding to configuration:
There is actually two issues. The first is that node is crashing when trying to sync directories. Here is the error:
Here is the script:
The second which may be causing the issue, is the multipart sizes are not responding to configuration: