1.0.1 • Published 7 years ago

aeris-s3-sync v1.0.1

Weekly downloads
74
License
ISC
Repository
github
Last release
7 years ago

s3-sync

Node.js wrapper around the AWS CLI S3 sync command

Why would I use this instead of node-s3-client?

In order to compare files, node-s3-client attempts to reimplement the hashing algorithm used by the AWS API in creating an s3 object's etag. My experience is that is doesn't always work (especially with large files).

This library uses the AWS CLI tool, which -- though it also re-implements the hashing algorithm -- it at least supported by the same team which created the algorithm.

s3-sync also:

  • Locks download paths, meaning it will not allow you to download an object from s3 to the same local file path.
  • Resolves with a list of downloaded files paths

Usage

const s3Client = S3Client({
  accessKeyId: 'testId',
  secretAccessKey: 'testKey',
  region: 'testRegion'
});

s3Client.sync('s3://my-bucket/foo/bar', '/local/foo/bar', {
  // set to `true` to enable the --delete flag
  delete: false,
  // Accepts a stream.Writable, to which the `s3 sync` stdout will be piped
  stdout: process.stdout
  // Accepts a stream.Writable, to which the `s3 sync` stderr will be piped
  stdout: process.stdout
})
  .then(res => {
    // res.stdout is the stdout from the `s3 sync` command
    // res.stderr is the stderr from the `s3 sync` command
    // res.files is an array of downloaded file paths
  })

s3Client.sync also accepts error-first callbacks, for example:

s3Client.sync(from, to, opts, (err, res) => {
    // res.stdout is the stdout from the `s3 sync` command
    // res.stderr is the stderr from the `s3 sync` command
    // res.files is an array of downloaded file paths
});
1.0.1

7 years ago

1.0.0

8 years ago