Skip to content

Instantly share code, notes, and snippets.

@agutoli
Created August 28, 2018 15:42
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 agutoli/00d37a041e77da5036b37f523d0c9425 to your computer and use it in GitHub Desktop.
Save agutoli/00d37a041e77da5036b37f523d0c9425 to your computer and use it in GitHub Desktop.
const s3 = require('s3');
const path = require('path');
const fs = require('fs');
const distDir = path.join(path.dirname(fs.realpathSync(__filename)), '../DIRETORIO_COM_ARQUIVOS');
const client = s3.createClient({
s3Options: {
// accessKeyId: '',
// secretAccessKey: '',
region: 'us-east-1'
}
});
const params = {
localDir: distDir,
s3Params: {
Bucket: 'SEU_BUCKET',
ACL: 'public-read'
}
};
const uploader = client.uploadDir(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