Created
January 29, 2015 13:12
-
-
Save jeffdonthemic/efa1e0563fc0f641ad4e to your computer and use it in GitHub Desktop.
Download file from S3 to disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "accessKeyId": "akid", "secretAccessKey": "secret", "region": "us-east-1" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require('aws-sdk'); | |
AWS.config.loadFromPath('./config.json'); | |
// get reference to S3 client | |
var s3 = new AWS.S3(); | |
var bucket = 'jeffdonthemic-demos'; | |
var file = 'index.js'; | |
var params = {Bucket: bucket, Key: file}; | |
var file = require('fs').createWriteStream('./foo.js'); | |
s3.getObject(params).createReadStream().pipe(file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment