Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
Created January 29, 2015 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffdonthemic/efa1e0563fc0f641ad4e to your computer and use it in GitHub Desktop.
Save jeffdonthemic/efa1e0563fc0f641ad4e to your computer and use it in GitHub Desktop.
Download file from S3 to disk
{ "accessKeyId": "akid", "secretAccessKey": "secret", "region": "us-east-1" }
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