Skip to content

Commit b20988e

Browse files
authored
docs: add file upload docs (#866)
1 parent 1a0bb47 commit b20988e

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

_includes/parse-server/file-adapters.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# Configuring File Upload
2+
3+
*Available on Parse Server >=5.0.0*
4+
5+
Parse Server restricts file upload to authenticated users only to improve Parse Server's default security. This behaviour can be modified by specifying `fileUpload` options to your Parse Server configuration.
6+
7+
Available options are:
8+
9+
- `enableForAnonymousUser`: Enable file upload for anonymous users
10+
- `enableForAuthenticatedUser`: Enable file upload for authenticated users
11+
- `enableForPublic`: Enable file upload for the public, i.e. everyone
12+
13+
To allow public file uploads to Parse Server:
14+
15+
```javascript
16+
const api = new ParseServer({
17+
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
18+
cloud: process.env.PARSE_SERVER_CLOUD || __dirname + '/cloud/main.js',
19+
appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
20+
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
21+
fileUpload: {
22+
enableForPublic: true,
23+
enableForAnonymousUser: true,
24+
enableForAuthenticatedUser: true,
25+
}
26+
});
27+
```
28+
129
# Configuring File Adapters
230

331
Parse Server allows developers to choose from several options when hosting files:
@@ -22,8 +50,8 @@ File encryption is available in parse-server 4.4.0+. The `GridStoreAdapter` can
2250

2351
To use, simply do any of the following:
2452
- Use the environment variable `PARSE_SERVER_ENCRYPTION_KEY`
25-
- Pass in --encryptionKey in the command line when starting your server
26-
- Initialize ParseServer with `encryptionKey="Your file encryptionKey"`.
53+
- Pass the encryption key via parameter `--encryptionKey` in the command line when starting Parse Server
54+
- Initialize Parse Server with `encryptionKey="PATH_TO_ENCRYPTION_KEY_FILE`.
2755

2856
An example starting your Parse Server in `index.js` is below:
2957

@@ -32,13 +60,13 @@ const api = new ParseServer({
3260
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
3361
cloud: process.env.PARSE_SERVER_CLOUD || __dirname + '/cloud/main.js',
3462
appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
35-
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
63+
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
3664
encryptionKey: process.env.PARSE_SERVER_ENCRYPTION_KEY, //Add your file key here. Keep it secret
3765
...
3866
});
3967
```
4068

41-
Be sure not to lose your key or change it after encrypting files.
69+
Be sure not to lose your key or change it after encrypting files.
4270

4371
### Enabling encryption on a server that already has unencrypted files
4472
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter as above with the new key and do the following after initialization in your `index.js`:
@@ -69,7 +97,7 @@ const api = new ParseServer({
6997
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
7098
cloud: process.env.PARSE_SERVER_CLOUD || __dirname + '/cloud/main.js',
7199
appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
72-
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
100+
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
73101
//No encryptionKey here
74102
...
75103
});
@@ -358,7 +386,7 @@ var api = new ParseServer({
358386
})
359387
```
360388

361-
Be sure not to lose your key or change it after encrypting files.
389+
Be sure not to lose your key or change it after encrypting files.
362390

363391
### Enabling encryption on a server that already has unencrypted files
364392
When this is the case, it is recommended to start up a development parse-server (or a separate process from your main process) that has the same configuration as your production server. On the development server, initialize the file adapter as above with the new key and do the following after initialization in your `index.js`:
@@ -389,7 +417,7 @@ const api = new ParseServer({
389417
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
390418
cloud: process.env.PARSE_SERVER_CLOUD || __dirname + '/cloud/main.js',
391419
appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
392-
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
420+
masterKey: process.env.PARSE_SERVER_MASTER_KEY || '',
393421
filesAdapter: new FSFilesAdapter(), //No encryptionKey supplied
394422
...
395423
});

0 commit comments

Comments
 (0)