Revert "refactor: use aws-sdk-js instead of boto (#24863)"

This reverts commit a3581aa992.
This commit is contained in:
Samuel Attard 2020-08-22 16:42:45 -07:00
parent cd4c4e9f04
commit 1646f938f3
No known key found for this signature in database
GPG key ID: FB94249299E904FE
10 changed files with 138 additions and 158 deletions

View file

@ -1,38 +0,0 @@
/* eslint-disable camelcase */
const AWS = require('aws-sdk');
const fs = require('fs');
const path = require('path');
AWS.config.update({ region: 'us-west-2' });
const s3 = new AWS.S3({ apiVersion: '2006-03-01' });
const args = require('minimist')(process.argv.slice(2));
let { bucket, prefix = '/', key_prefix = '', grant, _: files } = args;
if (prefix && !prefix.endsWith(path.sep)) prefix = path.resolve(prefix) + path.sep;
function filenameToKey (file) {
file = path.resolve(file);
if (file.startsWith(prefix)) file = file.substr(prefix.length);
return key_prefix + file.replace(path.sep, '/');
}
let anErrorOccurred = false;
function next (done) {
const file = files.shift();
if (!file) return done();
s3.upload({
Bucket: bucket,
Key: filenameToKey(file),
Body: fs.createReadStream(file),
ACL: grant
}, (err, data) => {
if (err) {
console.error(err);
anErrorOccurred = true;
}
next(done);
});
}
next(() => {
process.exit(anErrorOccurred ? 1 : 0);
});