aws-s3-connector
Amazon WebService S3 Connector
Last updated 5 years ago by intelisis .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install aws-s3-connector 
SYNC missed versions from official npm registry.

AWS S3 Connector

Tired of all the hassles downloading, removing from and uploading to Amazon S3? The solution is here!

Install

npm install --save aws-s3-connector

Initialize Bucket

  • With CoffeeScript
S3Connector = require 'aws-s3-connector'

Storage = new S3Connector
  credentials: './credentials/aws.json'
  Bucket: 'BUCKET_NAME'
  • With JavaScript
var S3Connector = require('aws-s3-connector');

var Storage = new S3Connector({
  credentials: './credentials/aws.json',
  Bucket: 'BUCKET_NAME'
});

Download File

The Bucket is already defined in the Storage! You only need to pass the folder and filename inside S3 as remoteFile.

download 'remoteFile', 'localFile', callback
# or
download 'remoteFile', Buffer, callback
  • With CoffeeScript
Storage.download 'from-nosql/test.json', './downloads/test.json', (err) ->
  return console.error err if err
  console.log 'file downloaded'
  • With JavaScript
Storage.download('from-nosql/test.json', './downloads/test.json', function(err) {
  if (err) {
    return console.error(err);
  }
  console.log('file downloaded');
});

Remove File(s)

remove 'remoteFile', callback
# or, to remove multiple files at once
remove ['remoteFile1', 'remoteFile2'], callback
  • With CoffeeScript
Storage.remove 'from-nosql/test.json', (err) ->
  return console.error err if err
  console.log 'file removed'
  • With JavaScript
Storage.remove('from-nosql/test.json', function(err) {
  if (err) {
    return console.error(err);
  }
  console.log('file removed');
});

Upload File

upload 'localFile', 'remoteFile', callback
# or
upload Buffer, 'remoteFile', callback
  • With CoffeeScript
Storage.upload './uploads/answer.json', 'from-kernel/answer.json', (err) ->
  return console.error err if err
  console.log 'file uploaded'
  • With JavaScript
Storage.upload('./uploads/answer.json', 'from-kernel/answer.json', function(err) {
  if (err) {
    return console.error(err);
  }
  console.log('file uploaded');
});

Options

  • The credentials json should be of the following format:

{
  "accessKeyId": "YOUR_ACCESS_KEY_ID",
  "secretAccessKey": "YOUR_SECRET_ACCESS_KEY",
  "region": "YOUR_REGION"
}

Current Tags

  • 0.0.5                                ...           latest (5 years ago)

4 Versions

  • 0.0.5                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |