Last active
July 27, 2016 15:12
-
-
Save kristelteng/3cbdae405f0c13329a4a9f44becf4868 to your computer and use it in GitHub Desktop.
s3_upload.js
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
async function documenter(options) { | |
options = _.defaults({}, options, { | |
tier: null, | |
schemas: {}, | |
menuIndex: 10, | |
docsFolder: rootdir.get() + '/docs', | |
references: [], | |
publish: process.env.NODE_ENV == 'production', | |
}); | |
// some code | |
if (options.publish) { | |
let creds = await auth.awsS3Credentials('read-write', 'taskcluster-raw-docs', 'testing/'); | |
let s3 = new aws.S3(creds.credentials); | |
let s3Stream = S3UploadStream(s3); | |
let upload = s3Stream.upload({ | |
Bucket: 'taskcluster-raw-docs', | |
Key: 'testing/latest.tar.gz', | |
}); | |
// handle progress | |
upload.on('part', function(details) { | |
console.log(details); | |
}); | |
let uploadPromise = new Promise((resolve, reject) => { | |
// handle upload completion | |
upload.on('uploaded', function(details) { | |
console.log(details); | |
resolve(details); | |
}); | |
// handle errors | |
upload.on('error', function(error) { | |
console.log(error); | |
reject(error); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment