salix/print/core/storage.js

17 lines
461 B
JavaScript
Raw Normal View History

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);
}
};