Skip to content

Commit

Permalink
Add support for additional S3-compatible providers
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay authored and palvarez89 committed Aug 10, 2022
1 parent 787d839 commit 2f2f0a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ Once you've done that, your config section should look like this:
}
```

Authentication is handled automatically by the client. Check
[Amazon's documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html)
for more information. You will need to grant your role these permissions to
your bucket:
Authentication can be handled in the config (by adding `keyId` and `keySecret` properties to the above example), or separately by the client SDK.
See [Amazon's documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html) for more information.

You will need to create an IAM user and retrieve an access key. The IAM user should have the the following permissions:

```json
{
Expand All @@ -274,6 +274,18 @@ your bucket:
}
```

**Alternative S3 API Providers:** A number of other storage providers support the S3 API (such as Linode, BackBlaze B2, etc). To use one of those providers, you will need to specify an endpoint in your config instead of a region:

```json
{
"type": "amazon-s3",
"bucket": "your-bucket-name",
"endpoint": "s3.example.backblazeb2.com",
"keyId": "9387200",
"keySecret": "H93lmz_93hla9jhdl/Example"
}
```

## Docker

### Build image
Expand Down
11 changes: 10 additions & 1 deletion lib/document_stores/amazon-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ var winston = require('winston');
var AmazonS3DocumentStore = function(options) {
this.expire = options.expire;
this.bucket = options.bucket;
this.client = new AWS.S3({region: options.region});

var config = {};
if(options.endpoint)
config.endpoint = new AWS.Endpoint(options.endpoint);
if(options.region)
config.region = options.region;
if(options.keyId && options.keySecret)
config.credentials = new AWS.Credentials({ accessKeyId: options.keyId, secretAccessKey: options.keySecret })

this.client = new AWS.S3(config);
};

AmazonS3DocumentStore.prototype.get = function(key, callback, skipExpire) {
Expand Down

0 comments on commit 2f2f0a1

Please sign in to comment.