Skip to content

Instantly share code, notes, and snippets.

@astrotars

astrotars/1.js Secret

Created November 8, 2019 19:57
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 astrotars/669459dffb60b053cb71b18b440c5b26 to your computer and use it in GitHub Desktop.
Save astrotars/669459dffb60b053cb71b18b440c5b26 to your computer and use it in GitHub Desktop.
// async waterfall (see: https://github.com/caolan/async)
async.waterfall(
[
// upload file to amazon s3
function(cb) {
// initialize knox client
var knoxClient = knox.createClient({
key: config.s3.key,
secret: config.s3.secret,
bucket: config.s3.bucket,
});
// send put via knox
knoxClient.putFile(
file.image.path,
'uploads/' + data.filename,
{
'Content-Type': file.image.type,
'x-amz-acl': 'public-read',
},
function(err, result) {
if (err || result.statusCode != 200) {
cb(err);
} else {
cb(null);
}
},
);
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment