Skip to content

Instantly share code, notes, and snippets.

@adon-at-work
Created February 27, 2015 16:12
Show Gist options
  • Save adon-at-work/4102e0c6da80af019393 to your computer and use it in GitHub Desktop.
Save adon-at-work/4102e0c6da80af019393 to your computer and use it in GitHub Desktop.
Sample file on how to further upload files to S3
var AWS = require('aws-sdk'),
fs = require('fs');
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Disk
// AWS.config.loadFromPath('./aws-config.json');
// assume you already have the S3 Bucket created, and it is called ierg4210-shopxx-photos
var photoBucket = new AWS.S3({params: {Bucket: 'ierg4210-shopxx-photos'}});
// filepath equals the location of the uploaded file you got from multer
// pid is the destination product id
photoBucket.upload({ACL: 'public-read', Body: fs.createReadStream(filepath), Key: pid.toString()})
.on('httpUploadProgress', function(evt) { console.log(evt); })
.send(function(err, data) { console.log(err, data) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment