mailtrain/lib/file-helpers.js
Tomas Bures 7788b0bc67 Fixed sandbox. Multiple tabs work now.
WiP on selectable mosaico templates.

TODO: Make files always point to trusted URL, such that we don't have to rebase them. They are public anyway. The same goes for mosaico endpoints: /mosaico/templates and /mosaico/img
2018-05-09 04:07:01 +02:00

21 lines
No EOL
623 B
JavaScript

'use strict';
const passport = require('./passport');
const files = require('../models/files');
const path = require('path');
const uploadedFilesDir = path.join(files.filesDir, 'uploaded');
const multer = require('multer')({
dest: uploadedFilesDir
});
function installUploadHandler(router, url, getUrl = null, dontReplace = false) {
router.postAsync(url, passport.loggedIn, multer.array('files[]'), async (req, res) => {
return res.json(await files.createFiles(req.context, req.params.type, req.params.entityId, req.files, getUrl, dontReplace));
});
}
module.exports = {
installUploadHandler
};