Skip to content

Instantly share code, notes, and snippets.

@kristelteng
Last active July 27, 2016 15:12
Show Gist options
  • Save kristelteng/3cbdae405f0c13329a4a9f44becf4868 to your computer and use it in GitHub Desktop.
Save kristelteng/3cbdae405f0c13329a4a9f44becf4868 to your computer and use it in GitHub Desktop.
s3_upload.js
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