Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Add support for additional S3-compatible providers #399

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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