Reputation: 7751
Amazon Web Services - Command Line Interface (AWS-CLI) has a sync command. Unfortunately AWS CLI's sync
method is a bit buggy. I'd like to sync to S3 using a gulp build process and Amazon's javascript/node SDK.
Unfortunately, the SDK doesn't seem to have a sync method, or does it?
What is the best way to sync whole directories in Node with AWS S3?
Upvotes: 26
Views: 5301
Reputation: 5995
2022 Update:
aws s3 sync
is still only available with CLI. Most of the AWS SDKs still don't implement s3 sync. I found an npm library which does a decent job. Please checkout s3-sync-client. There are many alternatives in javascript but they have their limitations w.r.t. sync. This package overcomes almost all of them.
Upvotes: 1
Reputation: 55
The AWS CLI is more stable now. So, my solution:
gulp.task("sync-buckets", done => {
let conf = loadConf();
exec(`aws s3 sync --acl public-read bucket/www_static/ s3://${conf.BucketName}`, done);
});
Upvotes: 0