1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-01 03:21:21 +00:00

Add support for additional S3-compatible providers

This commit is contained in:
Caelan Sayler 2021-12-01 15:41:53 +00:00
parent 7af15cc32d
commit 3f7aa64d15
2 changed files with 26 additions and 5 deletions

View file

@ -253,10 +253,10 @@ Once you've done that, your config section should look like this:
} }
``` ```
Authentication is handled automatically by the client. Check Authentication can be handled in the config (by adding `keyId` and `keySecret` properties to the above example), or separately by the client SDK.
[Amazon's documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html) See [Amazon's documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html) for more information.
for more information. You will need to grant your role these permissions to
your bucket: You will need to create an IAM user and retrieve an access key. The IAM user should have the the following permissions:
```json ```json
{ {
@ -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 ## Docker
### Build image ### Build image

View file

@ -6,7 +6,16 @@ var winston = require('winston');
var AmazonS3DocumentStore = function(options) { var AmazonS3DocumentStore = function(options) {
this.expire = options.expire; this.expire = options.expire;
this.bucket = options.bucket; 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) { AmazonS3DocumentStore.prototype.get = function(key, callback, skipExpire) {