Created
February 27, 2015 16:12
-
-
Save adon-at-work/4102e0c6da80af019393 to your computer and use it in GitHub Desktop.
Sample file on how to further upload files to S3
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'), | |
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