-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
33 lines (26 loc) · 847 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict'
const Subsume = require('subsume-limited')
class MultiFilesAdapter {
constructor (options) {
this._subsume = new Subsume(options.id)
this._adapters = options.adapters
this._defaultAdapter = options.defaultAdapter
}
createFile (filename, data, contentType) {
return this._getAdapter(filename).createFile(filename, data, contentType)
}
deleteFile (filename) {
return this._getAdapter(filename).deleteFile(filename)
}
getFileData (filename) {
return this._getAdapter(filename).getFileData(filename)
}
getFileLocation (config, filename) {
return this._getAdapter(filename).getFileLocation(config, filename)
}
_getAdapter (filename) {
const key = this._subsume.parse(filename).data || this._defaultAdapter
return this._adapters[key]
}
}
module.exports = MultiFilesAdapter