17 lines
461 B
JavaScript
17 lines
461 B
JavaScript
const config = require('./config.js');
|
|
const path = require('path');
|
|
const fs = require('fs-extra');
|
|
|
|
module.exports = {
|
|
async write(buffer, options) {
|
|
const storage = config.storage[options.type];
|
|
if (!storage) return;
|
|
|
|
const src = path.join(storage.root, options.path);
|
|
const fileSrc = path.join(src, options.fileName);
|
|
|
|
await fs.mkdir(src, {recursive: true});
|
|
await fs.writeFile(fileSrc, buffer);
|
|
}
|
|
};
|