make Prettier

This commit is contained in:
AJ ONeal 2021-01-26 16:48:15 -07:00
parent 498e8cca1c
commit ad0fa1f83b
3 changed files with 26 additions and 26 deletions

View File

@ -32,11 +32,11 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
console.log(resp.url); console.log(resp.url);
return fs.promises.writeFile(filepath, resp.body); return fs.promises.writeFile(filepath, resp.body);
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
if (err.response) { if (err.response) {
console.error(err.url); console.error(err.url);

View File

@ -41,7 +41,7 @@ module.exports = S3 = {
} }
var signed = aws4.sign( var signed = aws4.sign(
{ {
host: host || (bucket + '.s3.amazonaws.com'), host: host || bucket + '.s3.amazonaws.com',
service: 's3', service: 's3',
region: region, region: region,
path: (host ? '/' + bucket : '') + '/' + prefix + key, path: (host ? '/' + bucket : '') + '/' + prefix + key,
@ -91,7 +91,7 @@ module.exports = S3 = {
} }
var signed = aws4.sign( var signed = aws4.sign(
{ {
host: host || (bucket + '.s3.amazonaws.com'), host: host || bucket + '.s3.amazonaws.com',
service: 's3', service: 's3',
region: region, region: region,
path: (host ? '/' + bucket : '') + '/' + prefix + key, path: (host ? '/' + bucket : '') + '/' + prefix + key,
@ -152,7 +152,7 @@ module.exports = S3 = {
} }
var signed = aws4.sign( var signed = aws4.sign(
{ {
host: host || (bucket + '.s3.amazonaws.com'), host: host || bucket + '.s3.amazonaws.com',
service: 's3', service: 's3',
region: region, region: region,
path: (host ? '/' + bucket : '') + '/' + prefix + key, path: (host ? '/' + bucket : '') + '/' + prefix + key,
@ -196,7 +196,7 @@ module.exports = S3 = {
} }
var signed = aws4.sign( var signed = aws4.sign(
{ {
host: host || (bucket + '.s3.amazonaws.com'), host: host || bucket + '.s3.amazonaws.com',
service: 's3', service: 's3',
region: region, region: region,
path: (host ? '/' + bucket : '') + '/' + prefix + key, path: (host ? '/' + bucket : '') + '/' + prefix + key,

40
test.js
View File

@ -32,11 +32,11 @@ async function run() {
body: stream, body: stream,
size size
}) })
.then(function(resp) { .then(function (resp) {
console.info('PASS: stream uploaded file'); console.info('PASS: stream uploaded file');
return null; return null;
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
console.error('PUT Response:'); console.error('PUT Response:');
if (err.response) { if (err.response) {
@ -62,11 +62,11 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
console.info('PASS: streamed file exists'); console.info('PASS: streamed file exists');
return null; return null;
}) })
.catch(function(err) { .catch(function (err) {
console.error('HEAD Response:'); console.error('HEAD Response:');
if (err.response) { if (err.response) {
console.error(err.response.statusCode); console.error(err.response.statusCode);
@ -87,7 +87,7 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
if (file.toString('binary') === resp.body.toString('binary')) { if (file.toString('binary') === resp.body.toString('binary')) {
console.info( console.info(
'PASS: streamed file downloaded with same contents' 'PASS: streamed file downloaded with same contents'
@ -96,7 +96,7 @@ async function run() {
} }
throw new Error("file contents don't match"); throw new Error("file contents don't match");
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
console.error('GET Response:'); console.error('GET Response:');
if (err.response) { if (err.response) {
@ -118,11 +118,11 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
console.info('PASS: delete file'); console.info('PASS: delete file');
return null; return null;
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
console.error('DELETE Response:'); console.error('DELETE Response:');
if (err.response) { if (err.response) {
@ -144,12 +144,12 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
var err = new Error('file should not exist'); var err = new Error('file should not exist');
err.response = resp; err.response = resp;
throw err; throw err;
}) })
.catch(function(err) { .catch(function (err) {
if (err.response && 404 === err.response.statusCode) { if (err.response && 404 === err.response.statusCode) {
console.info('PASS: streamed file deleted'); console.info('PASS: streamed file deleted');
return null; return null;
@ -176,11 +176,11 @@ async function run() {
key, key,
body: file body: file
}) })
.then(function(resp) { .then(function (resp) {
console.info('PASS: one-shot upload'); console.info('PASS: one-shot upload');
return null; return null;
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
console.error('PUT Response:'); console.error('PUT Response:');
if (err.response) { if (err.response) {
@ -206,11 +206,11 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
console.info('PASS: one-shot upload exists'); console.info('PASS: one-shot upload exists');
return null; return null;
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
console.error('HEAD Response:'); console.error('HEAD Response:');
if (err.response) { if (err.response) {
@ -232,7 +232,7 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
if (file.toString('binary') === resp.body.toString('binary')) { if (file.toString('binary') === resp.body.toString('binary')) {
console.info( console.info(
'PASS: one-shot file downloaded with same contents' 'PASS: one-shot file downloaded with same contents'
@ -241,7 +241,7 @@ async function run() {
} }
throw new Error("file contents don't match"); throw new Error("file contents don't match");
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
console.error('GET Response:'); console.error('GET Response:');
if (err.response) { if (err.response) {
@ -263,11 +263,11 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
console.info('PASS: DELETE'); console.info('PASS: DELETE');
return null; return null;
}) })
.catch(function(err) { .catch(function (err) {
console.error('Error:'); console.error('Error:');
console.error('DELETE Response:'); console.error('DELETE Response:');
if (err.response) { if (err.response) {
@ -289,12 +289,12 @@ async function run() {
prefix, prefix,
key key
}) })
.then(function(resp) { .then(function (resp) {
var err = new Error('file should not exist'); var err = new Error('file should not exist');
err.response = resp; err.response = resp;
throw err; throw err;
}) })
.catch(function(err) { .catch(function (err) {
if (err.response && 404 === err.response.statusCode) { if (err.response && 404 === err.response.statusCode) {
console.info('PASS: streamed file deleted'); console.info('PASS: streamed file deleted');
return null; return null;