Skip to content

Commit 23108ac

Browse files
authored
docs: add s3 adapter examples for Linode and Backblaze (#825)
1 parent feb3dbb commit 23108ac

File tree

1 file changed

+55
-41
lines changed

1 file changed

+55
-41
lines changed

_includes/parse-server/file-adapters.md

+55-41
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ var api = new ParseServer({
175175

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

178-
##### S3Adapter constructor options
178+
### Adapter Options
179179

180180
```js
181181
new S3Adapter(accessKey, secretKey, bucket, options)
@@ -194,6 +194,60 @@ new S3Adapter(accessKey, secretKey, bucket, options)
194194
| 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`. |
195195
| 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). |
196196

197+
### S3-compatible Services
198+
#### Digital Ocean Spaces
199+
200+
[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.
201+
202+
```javascript
203+
const s3Options = {
204+
bucket: "SPACES_BUCKET_NAME",
205+
baseUrl: "SPACES_BASE_URL",
206+
region: "SPACES_REGION",
207+
bucketPrefix: "SPACES_BUCKET_PREFIX",
208+
s3overrides: {
209+
accessKeyId: "SPACES_ACCESS_KEY",
210+
secretAccessKey: "SPACES_SECRET_KEY",
211+
endpoint: 'SPACES_ENDPOINT'
212+
}
213+
};
214+
```
215+
216+
#### Linode Object Storage
217+
218+
[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.
219+
220+
```js
221+
const s3Options = {
222+
bucket: "S3_BUCKET_NAME",
223+
baseUrl: "S3_BASE_URL", // https://myBucket.myRegion.linodeobjects.com
224+
region: "S3_REGION", // possible values: eu-central-1 or us-east-1
225+
s3overrides: {
226+
accessKeyId: "S3_ACCESS_KEY", // bucket access key
227+
secretAccessKey: "S3_SECRET_KEY", // bucket secret key
228+
endpoint: "S3_ENDPOINT", // regionName.linodeobjects.com
229+
},
230+
};
231+
```
232+
233+
#### Backblaze B2 Cloud Storage
234+
235+
[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.
236+
237+
```js
238+
const s3Options = {
239+
bucket: "S3_BUCKET",
240+
baseUrl: "S3_BASE_URL", // taken from BackBlaze, normally https://BUCKET.s3.REGION.backblazeb2.com
241+
signatureVersion: 'v4',
242+
region: 'us-west-000',
243+
s3overrides: {
244+
endpoint: "S3_ENDPOINT", // check backblaze bucket endpoint
245+
accessKeyId: "S3_ACCESS_KEY",
246+
secretAccessKey: "S3_SECRET_KEY"
247+
},
248+
};
249+
```
250+
197251

198252
## Configuring `GCSAdapter`
199253

@@ -249,46 +303,6 @@ var api = new ParseServer({
249303
});
250304
```
251305

252-
##### S3Adapter configuration for Digital Ocean Spaces
253-
254-
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.
255-
You just need to change the AWS Endpoint to point to your Spaces endpoint.
256-
257-
```javascript
258-
...
259-
var S3Adapter = require('parse-server').S3Adapter;
260-
var AWS = require("aws-sdk");
261-
262-
//Set Digital Ocean Spaces EndPoint
263-
const spacesEndpoint = new AWS.Endpoint(process.env.SPACES_ENDPOINT);
264-
//Define S3 options
265-
var s3Options = {
266-
bucket: process.env.SPACES_BUCKET_NAME,
267-
baseUrl: process.env.SPACES_BASE_URL,
268-
region: process.env.SPACES_REGION,
269-
directAccess: true,
270-
globalCacheControl: "public, max-age=31536000",
271-
bucketPrefix: process.env.SPACES_BUCKET_PREFIX,
272-
s3overrides: {
273-
accessKeyId: process.env.SPACES_ACCESS_KEY,
274-
secretAccessKey: process.env.SPACES_SECRET_KEY,
275-
endpoint: spacesEndpoint
276-
}
277-
};
278-
279-
var s3Adapter = new S3Adapter(s3Options);
280-
281-
var api = new ParseServer({
282-
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
283-
appId: process.env.APP_ID || 'APPLICATION_ID',
284-
masterKey: process.env.MASTER_KEY || 'MASTER_KEY',
285-
...
286-
filesAdapter: s3Adapter
287-
...
288-
});
289-
```
290-
291-
292306
##### GCSAdapter constructor options
293307

294308
```js

0 commit comments

Comments
 (0)