You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using parse-server-fs-adapter across multiple parse-server instances it's important to establish "centralization" of your file storage (this is the same premise as the other file adapters, you are sending/recieving files through a dedicated link). You can accomplish this at the file storage level by Samba mounting (or any other type of mounting) your storage to each of your parse-server instances, e.g if you are using parse-server via docker (volume mount your SMB drive to `- /Volumes/SMB-Drive/MyParseApp1/files:/parse-server/files`). All parse-server instances need to be able to read and write to the same storage in order for parse-server-fs-adapter to work properly with parse-server. If the file storage isn't centralized, parse-server will have trouble locating files and you will get random behavior on client-side.
"filesSubDirectory":"my/files/folder", //optional, defaults to ./files
31
-
"encryptionKey":"someKey"//optional, but mandatory if you want to encrypt files
42
+
"filesSubDirectory":"my/files/folder", //Optional, defaults to `./files`
43
+
"encryptionKey":"someKey"// Optional, but mandatory if you want to encrypt files
32
44
}
33
45
}
34
46
}
35
47
```
36
48
37
-
### Passing as an instance
49
+
##In-Code Instance
38
50
39
51
```javascript
40
52
var FSFilesAdapter =require('@parse/fs-files-adapter');
@@ -51,48 +63,56 @@ var api = new ParseServer({
51
63
})
52
64
```
53
65
54
-
### Rotating to a new encryptionKey
55
-
Periodically you may want to rotate your encryptionKey for security reasons. When this is the case, you can start up a development parse-server that has the same configuration as your production server. In the development server, initialize the file adapter with the new key and do the following in your `index.js`:
66
+
## Rotating Encryption Key
67
+
68
+
Periodically you may want to rotate your encryptionKey for security reasons. When this is the case, you can start up a development parse-server that has the same configuration as your production server. In the development server, initialize the file adapter with the new key and use the examples below.
69
+
70
+
Note that the examples below to rotate keys are are not optimized for performance. Is it therefore not recommended to rotate a large number of files using the code below in a production environment; instead use dedicated resources for that.
71
+
72
+
### Encrypting Previously Unencrypted Files
56
73
57
-
#### Files were previously unencrypted and you want to encrypt
58
74
```javascript
59
75
var FSFilesAdapter =require('@parse/fs-files-adapter');
60
76
61
77
var fsAdapter =newFSFilesAdapter({
62
-
"filesSubDirectory":"my/files/folder", //optional, defaults to ./files
63
-
"encryptionKey":"newKey"//Use the newKey
78
+
"filesSubDirectory":"my/files/folder", //Optional, defaults to `./files`
79
+
"encryptionKey":"newKey"//Use the new key
64
80
});
65
81
66
82
var api =newParseServer({
67
83
appId:'my_app',
68
84
masterKey:'master_key',
69
85
filesAdapter: fsAdapter
70
-
})
86
+
});
71
87
72
-
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
73
-
//It is not recommended to do this on the production server, deploy a development server to complete the process.
console.log('Files rotated to newKey: '+ rotated);
76
-
console.log('Files that couldn't be rotated to newKey:' + notRotated);
90
+
console.log('Files that couldn\'t be rotated to newKey: '+ notRotated);
77
91
```
78
92
79
93
After successfully rotating your key, you should change the `encryptionKey` to `newKey` on your production server and then restart the server.
80
94
81
95
82
-
#### Files were previously encrypted with `oldKey` and you want to encrypt with `newKey`
83
-
The same process as above, but pass in your `oldKey` to `rotateEncryptionKey()`.
96
+
### Encrypting Previously Encrypted Files
97
+
98
+
To encrypt files with a new key that were previously encrypted with a different key, the same process applies as above, but you pass in your `oldKey` to `rotateEncryptionKey()`.
99
+
84
100
```javascript
85
-
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
console.log('Files rotated to newKey: '+ rotated);
88
-
console.log('Files that couldn't be rotated to newKey: '+ notRotated);
103
+
console.log('Files that couldn\'t be rotated to newKey: '+ notRotated);
89
104
```
90
105
91
-
#### Only rotate a select list of files that were previously encrypted with `oldKey` and you want to encrypt with `newKey`
92
-
This is useful if for some reason there errors and some of the files werent rotated and returned in `notRotated`. The same process as above, but pass in your `oldKey` along with the array of `fileNames` to `rotateEncryptionKey()`.
106
+
You can also only rotate a select list of files that were previously encrypted with `oldKey` and you want to encrypt with `newKey`. This is useful if for some reason there errors and some of the files werent rotated and returned in `notRotated`. The same process as above, but pass in your `oldKey` along with the array of `fileNames` to `rotateEncryptionKey()`.
107
+
93
108
```javascript
94
-
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
console.log('Files rotated to newKey: '+ rotated);
97
-
console.log('Files that couldn't be rotated to newKey:' + notRotated);
111
+
console.log('Files that couldn\'t be rotated to newKey: '+ notRotated);
98
112
```
113
+
114
+
# Other Considerations
115
+
116
+
- Multiple Instances of Parse Server
117
+
118
+
When using the adapter across multiple Parse Server instances it's important to establish "centralization" of your file storage (this is the same premise as the other file adapters, you are sending/receiving files through a dedicated link). You can accomplish this at the file storage level by Samba mounting (or any other type of mounting) your storage to each of your parse-server instances, e.g if you are using parse-server via docker (volume mount your SMB drive to `- /Volumes/SMB-Drive/MyParseApp1/files:/parse-server/files`). All parse-server instances need to be able to read and write to the same storage in order for parse-server-fs-adapter to work properly with parse-server. If the file storage isn't centralized, parse-server will have trouble locating files and you will get random behavior on client-side.
0 commit comments