AWS S3 Sync with JS/Node SDK
Asked Answered
F

2

25

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?

Febri answered 17/4, 2014 at 9:8 Comment(3)
github.com/pgherveou/gulp-awspublishBotnick
Has anyone found out why aws-sdk doesn't offer a sync method? Here is the list of methods, and sync isn't in there: docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.htmlReproduce
You could use High Level Amazon S3 Client node-package, it has a sync option: npmjs.com/package/s3Statistician
D
1

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.

Darien answered 27/8, 2022 at 18:30 Comment(0)
M
0

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);
});
Mccray answered 16/10, 2016 at 18:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.