parse-server-multi-files-adapter
Allows multiple file adapters to be used at the same time by specifying the adapter in the filename.
Installation
yarn add parse-server-multi-files-adapter
or
npm install --save parse-server-multi-files-adapter
Usage
Server
For now, must be passed as an instance to the parse-server constructor:
const MultiFilesAdapter = const FSFilesAdapter = const S3Adapter = const GCSAdapter = const multiAdapter = // Delimiter used to retrieve adapter key // Never change this id: 'unique' // Dictionary of file adapters adapters: local: s3: // options... gcs1: // options... gcs2: // options... // The key of the file adapter to use if none specified // Never change this defaultAdapter: 's3' const api = appId: 'app_id' masterKey: 'master_key' filesAdapter: multiAdapter
Client
The adapter key (corresponding to a key in the adapters
object above) must be embedded in the filename.
This uses subsume-limited to parse the filename and determine the adapter key.
If writing a JS app you could do something like this to help create files:
// Utilsconst Subsume = const subsume = 'unique' // same id that was passed to constructor on server { return subsume + filename} { return subsumerest} { return data type} // Usageconst file = file
The saved file name in the example above would be Qq-unique-qQlocalZz-unique-zZfoobar.txt
.
If not using JS, you can replicate that functionality:
ID = Delimiter you chose
AdapterKey = Key of adapter to use
prefix = "Qq-" + ID + "-qQ"
suffix = "Zz-" + ID + "-zZ"
composed = prefix + AdapterKey + suffix
filename = composed + original file name