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 = credentials: './credentials/aws.json' Bucket: 'BUCKET_NAME'
- With JavaScript
var S3Connector = ; var Storage = 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
Storagedownload 'from-nosql/test.json''./downloads/test.json' return consoleerror err if err consolelog 'file downloaded'
- With JavaScript
Storage;
Remove File(s)
remove 'remoteFile', callback# or, to remove multiple files at once remove ['remoteFile1', 'remoteFile2'], callback
- With CoffeeScript
Storageremove 'from-nosql/test.json' return consoleerror err if err consolelog 'file removed'
- With JavaScript
Storage;
Upload File
upload 'localFile', 'remoteFile', callback# or upload Buffer, 'remoteFile', callback
- With CoffeeScript
Storageupload './uploads/answer.json''from-kernel/answer.json' return consoleerror err if err consolelog 'file uploaded'
- With JavaScript
Storage;
Options
- The credentials json should be of the following format: