mirror of https://github.com/therootcompany/s3.js
v1.0.2: improve docs and error messages
This commit is contained in:
parent
b5a06a587f
commit
857a7aa76c
|
@ -1,3 +1,4 @@
|
|||
.env
|
||||
.env*
|
||||
node_modules
|
||||
.*.sw*
|
||||
|
|
10
README.md
10
README.md
|
@ -17,6 +17,14 @@ s3.set({
|
|||
bucket,
|
||||
prefix,
|
||||
key,
|
||||
body
|
||||
body,
|
||||
size
|
||||
})
|
||||
```
|
||||
|
||||
If the body is a stream then `size` must be set to `fs.statSync(filePath).size`, or the request will fail:
|
||||
|
||||
```
|
||||
501
|
||||
<Code>NotImplemented</Code><Message>A header you provided implies functionality that is not implemented</Message>
|
||||
```
|
||||
|
|
|
@ -4,7 +4,7 @@ require('dotenv').config();
|
|||
var env = process.env;
|
||||
var s3 = require('../index.js');
|
||||
|
||||
var accessKeyId = env.AWS_ACCESS_KEY;
|
||||
var accessKeyId = env.AWS_ACCESS_KEY || env.AWS_ACCESS_KEY_ID;
|
||||
var secretAccessKey = env.AWS_SECRET_ACCESS_KEY;
|
||||
var region = env.AWS_REGION;
|
||||
var bucket = env.AWS_BUCKET;
|
||||
|
@ -36,11 +36,12 @@ async function run() {
|
|||
})
|
||||
.catch(function(err) {
|
||||
console.error('Error:');
|
||||
console.error('GET Response:');
|
||||
if (err.response) {
|
||||
console.error(err.url);
|
||||
console.error('GET Response:');
|
||||
console.error(err.response.statusCode);
|
||||
console.error(err.response.headers);
|
||||
console.error(err.url);
|
||||
console.error(err.response.body.toString('utf8'));
|
||||
} else {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
4
index.js
4
index.js
|
@ -28,8 +28,8 @@ module.exports = {
|
|||
}
|
||||
*/
|
||||
/*
|
||||
if (env.AWS_ACCESS_KEY) {
|
||||
accessKeyId = accessKeyId || env.AWS_ACCESS_KEY;
|
||||
if (env.AWS_ACCESS_KEY || env.AWS_ACCESS_KEY_ID) {
|
||||
accessKeyId = accessKeyId || env.AWS_ACCESS_KEY || env.AWS_ACCESS_KEY_ID;
|
||||
secretAccessKey = secretAccessKey || env.AWS_SECRET_ACCESS_KEY;
|
||||
bucket = bucket || env.AWS_BUCKET;
|
||||
prefix = prefix || env.AWS_BUCKET_PREFIX;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@root/s3",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@root/s3",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "A simple, lightweight s3 client with only 2 dependencies",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
|
|
2
test.js
2
test.js
|
@ -4,7 +4,7 @@ require('dotenv').config();
|
|||
var env = process.env;
|
||||
var s3 = require('./index.js');
|
||||
|
||||
var accessKeyId = env.AWS_ACCESS_KEY;
|
||||
var accessKeyId = env.AWS_ACCESS_KEY || env.AWS_ACCESS_KEY_ID;
|
||||
var secretAccessKey = env.AWS_SECRET_ACCESS_KEY;
|
||||
var region = env.AWS_REGION;
|
||||
var bucket = env.AWS_BUCKET;
|
||||
|
|
Loading…
Reference in New Issue