Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
parse-server-multi-files-adapter
Advanced tools
Allows multiple file adapters to be used at the same time by specifying the adapter in the filename.
Allows multiple file adapters to be used at the same time by specifying the adapter in the filename.
yarn add parse-server-multi-files-adapter
or
npm install --save parse-server-multi-files-adapter
For now, must be passed as an instance to the parse-server constructor:
const MultiFilesAdapter = require('parse-server-multi-files-adapter')
const FSFilesAdapter = require('parse-server-fs-adapter')
const S3Adapter = require('parse-server-s3-adapter')
const GCSAdapter = require('parse-server-gcs-adapter')
const multiAdapter = new MultiFilesAdapter({
// Delimiter used to retrieve adapter key
// Never change this
id: 'unique',
// Dictionary of file adapters
adapters: {
local: new FSFilesAdapter(),
s3: new S3Adapter({
// options...
}),
gcs1: new GCSAdapter({
// options...
}),
gcs2: new GCSAdapter({
// options...
})
},
// The key of the file adapter to use if none specified
// Never change this
defaultAdapter: 's3'
})
const api = new ParseServer({
appId: 'app_id',
masterKey: 'master_key',
filesAdapter: multiAdapter
})
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:
// Utils
const Subsume = require('subsume-limited')
const subsume = new Subsume('unique') // same id that was passed to constructor on server
function composeFileName (adapterKey, filename) {
return subsume.compose(adapterKey) + filename
}
function getOriginalFileName (filename) {
return subsume.parse(filename).rest
}
function createParseFile (adapterKey, filename, data, type) {
return new Parse.File(composeFileName(adapterKey, filename), data, type)
}
// Usage
const file = createParseFile('local', 'foobar.txt', { base64: "TG9yZW0gSXBzdW0gRG9sb3I=" })
file.save()
.then(function () {
const foo = new Parse.Object('Foo')
foo.set('file', file)
return foo.save()
})
.then(function () {
console.log('Saved')
})
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
FAQs
Allows multiple file adapters to be used at the same time by specifying the adapter in the filename.
We found that parse-server-multi-files-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.