mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
Optimisations + lisibilité
This commit is contained in:
@@ -13,7 +13,7 @@ const ALLOWED_MIME = [
|
||||
"image/gif"
|
||||
]
|
||||
|
||||
//Setup multer (the file upload middleware)
|
||||
// Setup multer (the file upload middleware)
|
||||
const storage = multer.diskStorage({
|
||||
// Save the file in the uploads directory
|
||||
destination: function (req, file, callback) {
|
||||
@@ -27,7 +27,7 @@ const storage = multer.diskStorage({
|
||||
|
||||
const upload = multer({
|
||||
storage,
|
||||
//Only upload the file if it is a valid mime type and the team POST parameter is a valid team
|
||||
// Only upload the file if it is a valid mime type and the team POST parameter is a valid team
|
||||
fileFilter: function (req, file, callback) {
|
||||
if (ALLOWED_MIME.indexOf(file.mimetype) == -1) {
|
||||
callback(null, false);
|
||||
@@ -39,8 +39,7 @@ const upload = multer({
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
//Clean the uploads directory
|
||||
// Clean the uploads directory
|
||||
function clean() {
|
||||
const files = fs.readdirSync(UPLOAD_DIR);
|
||||
for (const file of files) {
|
||||
@@ -49,7 +48,6 @@ function clean() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function initPhotoUpload() {
|
||||
clean();
|
||||
//App handler for uploading a photo and saving it to a file
|
||||
|
||||
Reference in New Issue
Block a user