ADD: SignedUrls for documents, mainImage and images
ADD: Bucket and Upload System ADD: New errors ADD: Virtuals for categories ADD: Features system ADD: File management system
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const multer = require('multer')
|
||||
const AppError = require('../globalErrorHandler/AppError')
|
||||
|
||||
const types = ['png', 'jpg', 'jpeg', 'webp']
|
||||
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
|
||||
Reference in New Issue
Block a user