ADD: DocumentUrls and mainImageUrls field in belonging model FIX: Indexing bugs for belonging ADD: getImage endpoint to get private images ADD: PrivateUrl field as virtual FIX: Minor bug in bucketDeleteFile service ADD: Word type to multer file checker
25 lines
679 B
JavaScript
25 lines
679 B
JavaScript
const multer = require('multer')
|
|
const AppError = require('../globalErrorHandler/AppError')
|
|
|
|
const types = ['png', 'jpg', 'jpeg', 'webp', 'pdf', 'doc', 'docx', 'xlsx', 'dwg', 'vnd.openxmlformats-officedocument.wordprocessingml.document']
|
|
const formatsText = types.join(' - ')
|
|
|
|
const fileFilter = (req, file, cb) => {
|
|
if (types.includes(file.mimetype.split('/')[1])) cb(null, true)
|
|
else
|
|
cb(
|
|
new AppError('UnsupportedFileForUpload', 400, {
|
|
formats: formatsText,
|
|
}),
|
|
false
|
|
)
|
|
}
|
|
|
|
const upload = multer({
|
|
dest: './uploads/',
|
|
fileFilter,
|
|
limits: { fileSize: 10000000 },
|
|
})
|
|
|
|
module.exports = upload
|