34 lines
1.4 KiB
JavaScript
34 lines
1.4 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.faqPdfUpload = exports.FAQ_PDF_ALLOWED_MIMES = exports.FAQ_PDF_DEFAULT_MAX_BYTES = exports.FAQ_PDF_MULTER_CEILING_BYTES = void 0;
|
|
const multer_1 = __importDefault(require("multer"));
|
|
const uuid_1 = require("uuid");
|
|
const faqUpload_1 = require("./faqUpload");
|
|
/** Hard ceiling for multer; actual limit enforced via system_settings.faq_pdf_max_bytes. */
|
|
exports.FAQ_PDF_MULTER_CEILING_BYTES = 25 * 1024 * 1024;
|
|
exports.FAQ_PDF_DEFAULT_MAX_BYTES = 8 * 1024 * 1024;
|
|
exports.FAQ_PDF_ALLOWED_MIMES = new Set(['application/pdf']);
|
|
const storage = multer_1.default.diskStorage({
|
|
destination(_req, _file, cb) {
|
|
cb(null, (0, faqUpload_1.ensureFaqUploadDir)());
|
|
},
|
|
filename(_req, _file, cb) {
|
|
cb(null, `${(0, uuid_1.v4)()}.pdf`);
|
|
},
|
|
});
|
|
exports.faqPdfUpload = (0, multer_1.default)({
|
|
storage,
|
|
limits: { fileSize: exports.FAQ_PDF_MULTER_CEILING_BYTES, files: 1 },
|
|
fileFilter(_req, file, cb) {
|
|
if (exports.FAQ_PDF_ALLOWED_MIMES.has(file.mimetype)) {
|
|
cb(null, true);
|
|
}
|
|
else {
|
|
cb(new Error('Only PDF files are allowed'));
|
|
}
|
|
},
|
|
});
|
|
//# sourceMappingURL=faqPdfUpload.js.map
|