knox-copy

0.4.0 • Public • Published

knox-copy

Dependency Status

Extends the Knox Node Amazon S3 client to support copying and listing arbitrarily large buckets. Transparently streams keys and copies files from buckets that exceed Amazon's 1000 key page size limit.

Install

npm install knox-copy

Examples

Stream the keys of all the files in a bucket:

knoxCopy = require 'knox-copy'
 
client = knoxCopy.createClient
  key: '<api-key-here>'
  secret: '<secret-here>'
  bucket: 'mrbucket'
 
client.streamKeys(prefix: 'buckets/of/fun')
.on 'data'(key) -> console.log key

Backup a bucket full of uploads:

knoxCopy = require 'knox-copy'
 
client = knoxCopy.createClient
  key: '<api-key-here>'
  secret: '<secret-here>'
  bucket: 'backups'
 
client.copyBucket
  fromBucket: 'uploads'
  fromPrefix: '/nom-nom'
  toPrefix: "/upload_backups/#{new Date().toISOString()}"
  (err, count) ->
     console.log "Copied #{count} files"

Running Tests

Setup tests as with knox. You must first have an S3 account, and create a file named ./auth, which contains your credentials as json, for example:

{
  "key":"<api-key-here>",
  "secret":"<secret-here>",
  "bucket":"<your-bucket-name>"
}

Then install the dev dependencies and execute the test suite:

$ npm install
$ npm test

Dependencies (5)

Dev Dependencies (2)

Package Sidebar

Install

npm i knox-copy

Weekly Downloads

15

Version

0.4.0

License

MIT

Last publish

Collaborators

  • goodeggs-admin
  • hurrymaplelad