Skip to content

Commit

Permalink
docs: add s3 adapter examples for Linode and Backblaze (parse-communi…
Browse files Browse the repository at this point in the history
  • Loading branch information
alioguzhan authored Apr 21, 2022
1 parent feb3dbb commit 23108ac
Showing 1 changed file with 55 additions and 41 deletions.
96 changes: 55 additions & 41 deletions _includes/parse-server/file-adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var api = new ParseServer({

Don't forget to change **S3_ACCESS_KEY**, **S3_SECRET_KEY** and **S3_BUCKET** to their correct value.

##### S3Adapter constructor options
### Adapter Options

```js
new S3Adapter(accessKey, secretKey, bucket, options)
Expand All @@ -194,6 +194,60 @@ new S3Adapter(accessKey, secretKey, bucket, options)
| baseUrlDirect | Key in `options`. Is `true` if the file adapter should ignore the bucket prefix when determining the file location for direct access. | Optional. Default: `false`. To be used when `directAccess=true` and `baseUrl` is set. When set to `true`, the file adapter returns a file URL in format `baseUrl/filename`. Example for `baseUrl='http://domain.com/folder'` and `baseUrlDirect=true` the returned file location is `http://domain.com/folder/file.txt`. |
| globalCacheControl | Key in `options`. The `Cache-Control` http header to set in the file request. | Optional. Default: `null`. Example: `public, max-age=86400` for 24 hrs caching. More info [here](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1). |

### S3-compatible Services
#### Digital Ocean Spaces

[Digital Ocean Spaces](https://try.digitalocean.com/cloud-storage) is an S3-compatible storage service in the cloud. See their [documentation](https://docs.digitalocean.com/products/spaces/) for more details.

```javascript
const s3Options = {
bucket: "SPACES_BUCKET_NAME",
baseUrl: "SPACES_BASE_URL",
region: "SPACES_REGION",
bucketPrefix: "SPACES_BUCKET_PREFIX",
s3overrides: {
accessKeyId: "SPACES_ACCESS_KEY",
secretAccessKey: "SPACES_SECRET_KEY",
endpoint: 'SPACES_ENDPOINT'
}
};
```

#### Linode Object Storage

[Linode Object Storage](https://www.linode.com/products/object-storage/) is an S3-compatible storage service in the cloud. See their [documentation](https://www.linode.com/docs/guides/how-to-use-object-storage/) for more details.

```js
const s3Options = {
bucket: "S3_BUCKET_NAME",
baseUrl: "S3_BASE_URL", // https://myBucket.myRegion.linodeobjects.com
region: "S3_REGION", // possible values: eu-central-1 or us-east-1
s3overrides: {
accessKeyId: "S3_ACCESS_KEY", // bucket access key
secretAccessKey: "S3_SECRET_KEY", // bucket secret key
endpoint: "S3_ENDPOINT", // regionName.linodeobjects.com
},
};
```

#### Backblaze B2 Cloud Storage

[Backblaze B2 Cloud Storage](https://www.backblaze.com/b2/cloud-storage.html) is an S3-compatible storage service in the cloud. See their [documentation](https://www.backblaze.com/b2/docs/) for more details.

```js
const s3Options = {
bucket: "S3_BUCKET",
baseUrl: "S3_BASE_URL", // taken from BackBlaze, normally https://BUCKET.s3.REGION.backblazeb2.com
signatureVersion: 'v4',
region: 'us-west-000',
s3overrides: {
endpoint: "S3_ENDPOINT", // check backblaze bucket endpoint
accessKeyId: "S3_ACCESS_KEY",
secretAccessKey: "S3_SECRET_KEY"
},
};
```


## Configuring `GCSAdapter`

Expand Down Expand Up @@ -249,46 +303,6 @@ var api = new ParseServer({
});
```

##### S3Adapter configuration for Digital Ocean Spaces

Spaces is an S3 equivalent prodivided by Digital Ocean. It's use the same api as S3 so you can use it with the S3 Adapter.
You just need to change the AWS Endpoint to point to your Spaces endpoint.

```javascript
...
var S3Adapter = require('parse-server').S3Adapter;
var AWS = require("aws-sdk");

//Set Digital Ocean Spaces EndPoint
const spacesEndpoint = new AWS.Endpoint(process.env.SPACES_ENDPOINT);
//Define S3 options
var s3Options = {
bucket: process.env.SPACES_BUCKET_NAME,
baseUrl: process.env.SPACES_BASE_URL,
region: process.env.SPACES_REGION,
directAccess: true,
globalCacheControl: "public, max-age=31536000",
bucketPrefix: process.env.SPACES_BUCKET_PREFIX,
s3overrides: {
accessKeyId: process.env.SPACES_ACCESS_KEY,
secretAccessKey: process.env.SPACES_SECRET_KEY,
endpoint: spacesEndpoint
}
};

var s3Adapter = new S3Adapter(s3Options);

var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
appId: process.env.APP_ID || 'APPLICATION_ID',
masterKey: process.env.MASTER_KEY || 'MASTER_KEY',
...
filesAdapter: s3Adapter
...
});
```


##### GCSAdapter constructor options

```js
Expand Down

0 comments on commit 23108ac

Please sign in to comment.