2022-01-05 13:48:21 +00:00
|
|
|
const config = require('./config.js');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
|
|
|
module.exports = {
|
2023-04-04 13:00:28 +00:00
|
|
|
async write(buffer, options) {
|
2022-01-05 13:48:21 +00:00
|
|
|
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});
|
2023-04-04 13:00:28 +00:00
|
|
|
await fs.writeFile(fileSrc, buffer);
|
2022-01-05 13:48:21 +00:00
|
|
|
}
|
|
|
|
};
|