Git Product home page Git Product logo

s3-sync's Introduction

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
});

s3-sync's People

Contributors

danielmahon avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.