mirror of https://github.com/therootcompany/s3.js
make Prettier
This commit is contained in:
parent
498e8cca1c
commit
ad0fa1f83b
|
@ -32,11 +32,11 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
console.log(resp.url);
|
||||
return fs.promises.writeFile(filepath, resp.body);
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
if (err.response) {
|
||||
console.error(err.url);
|
||||
|
|
8
index.js
8
index.js
|
@ -41,7 +41,7 @@ module.exports = S3 = {
|
|||
}
|
||||
var signed = aws4.sign(
|
||||
{
|
||||
host: host || (bucket + '.s3.amazonaws.com'),
|
||||
host: host || bucket + '.s3.amazonaws.com',
|
||||
service: 's3',
|
||||
region: region,
|
||||
path: (host ? '/' + bucket : '') + '/' + prefix + key,
|
||||
|
@ -91,7 +91,7 @@ module.exports = S3 = {
|
|||
}
|
||||
var signed = aws4.sign(
|
||||
{
|
||||
host: host || (bucket + '.s3.amazonaws.com'),
|
||||
host: host || bucket + '.s3.amazonaws.com',
|
||||
service: 's3',
|
||||
region: region,
|
||||
path: (host ? '/' + bucket : '') + '/' + prefix + key,
|
||||
|
@ -152,7 +152,7 @@ module.exports = S3 = {
|
|||
}
|
||||
var signed = aws4.sign(
|
||||
{
|
||||
host: host || (bucket + '.s3.amazonaws.com'),
|
||||
host: host || bucket + '.s3.amazonaws.com',
|
||||
service: 's3',
|
||||
region: region,
|
||||
path: (host ? '/' + bucket : '') + '/' + prefix + key,
|
||||
|
@ -196,7 +196,7 @@ module.exports = S3 = {
|
|||
}
|
||||
var signed = aws4.sign(
|
||||
{
|
||||
host: host || (bucket + '.s3.amazonaws.com'),
|
||||
host: host || bucket + '.s3.amazonaws.com',
|
||||
service: 's3',
|
||||
region: region,
|
||||
path: (host ? '/' + bucket : '') + '/' + prefix + key,
|
||||
|
|
40
test.js
40
test.js
|
@ -32,11 +32,11 @@ async function run() {
|
|||
body: stream,
|
||||
size
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
console.info('PASS: stream uploaded file');
|
||||
return null;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
console.error('PUT Response:');
|
||||
if (err.response) {
|
||||
|
@ -62,11 +62,11 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
console.info('PASS: streamed file exists');
|
||||
return null;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('HEAD Response:');
|
||||
if (err.response) {
|
||||
console.error(err.response.statusCode);
|
||||
|
@ -87,7 +87,7 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
if (file.toString('binary') === resp.body.toString('binary')) {
|
||||
console.info(
|
||||
'PASS: streamed file downloaded with same contents'
|
||||
|
@ -96,7 +96,7 @@ async function run() {
|
|||
}
|
||||
throw new Error("file contents don't match");
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
console.error('GET Response:');
|
||||
if (err.response) {
|
||||
|
@ -118,11 +118,11 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
console.info('PASS: delete file');
|
||||
return null;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
console.error('DELETE Response:');
|
||||
if (err.response) {
|
||||
|
@ -144,12 +144,12 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
var err = new Error('file should not exist');
|
||||
err.response = resp;
|
||||
throw err;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
if (err.response && 404 === err.response.statusCode) {
|
||||
console.info('PASS: streamed file deleted');
|
||||
return null;
|
||||
|
@ -176,11 +176,11 @@ async function run() {
|
|||
key,
|
||||
body: file
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
console.info('PASS: one-shot upload');
|
||||
return null;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
console.error('PUT Response:');
|
||||
if (err.response) {
|
||||
|
@ -206,11 +206,11 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
console.info('PASS: one-shot upload exists');
|
||||
return null;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
console.error('HEAD Response:');
|
||||
if (err.response) {
|
||||
|
@ -232,7 +232,7 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
if (file.toString('binary') === resp.body.toString('binary')) {
|
||||
console.info(
|
||||
'PASS: one-shot file downloaded with same contents'
|
||||
|
@ -241,7 +241,7 @@ async function run() {
|
|||
}
|
||||
throw new Error("file contents don't match");
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
console.error('GET Response:');
|
||||
if (err.response) {
|
||||
|
@ -263,11 +263,11 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
console.info('PASS: DELETE');
|
||||
return null;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
console.error('Error:');
|
||||
console.error('DELETE Response:');
|
||||
if (err.response) {
|
||||
|
@ -289,12 +289,12 @@ async function run() {
|
|||
prefix,
|
||||
key
|
||||
})
|
||||
.then(function(resp) {
|
||||
.then(function (resp) {
|
||||
var err = new Error('file should not exist');
|
||||
err.response = resp;
|
||||
throw err;
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
if (err.response && 404 === err.response.statusCode) {
|
||||
console.info('PASS: streamed file deleted');
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue