Skip to content

Instantly share code, notes, and snippets.

@nicholasess
Created June 24, 2015 17:15
Show Gist options
  • Save nicholasess/9bcd047ac11fce46b15f to your computer and use it in GitHub Desktop.
Save nicholasess/9bcd047ac11fce46b15f to your computer and use it in GitHub Desktop.
s3
var s3 = require('s3');
var s3Options = {
accessKeyId: "",
secretAccessKey: ""
};
var awsS3Client = new AWS.S3(s3Options);
var options = {
s3Client: awsS3Client,
// more options available. See API docs below.
};
var client = s3.createClient(options);
var params = {
localFile: './upload/teste.png',
s3Params: {
Bucket: "welearnfs",
Key: "welearnfs/content_images"
}
}
var uploader = client.uploadFile(params);
uploader.on('error', function(err) {
console.error("unable to upload:", err.stack);
});
uploader.on('progress', function() {
console.log("progress", uploader.progressMd5Amount,
uploader.progressAmount, uploader.progressTotal);
});
uploader.on('end', function() {
console.log("done uploading");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment