Merge pull request #841 from PicPeak/chore/storage-ignore-dead-code
chore(backend): ignore runtime storage in git/docker, remove dead getSafeFilename
This commit is contained in:
+3
-2
@@ -130,5 +130,6 @@ docker-compose.dev.yml
|
|||||||
# New layout development files
|
# New layout development files
|
||||||
new-layouts/
|
new-layouts/
|
||||||
|
|
||||||
# Generated CRM/accounting documents (runtime) — never commit
|
# Backend runtime storage (generated media, previews, thumbnails,
|
||||||
backend/storage/business-docs/
|
# CRM/accounting documents) — never commit
|
||||||
|
backend/storage/
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
node_modules
|
node_modules
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
.env
|
.env
|
||||||
storage/events/active/*
|
storage
|
||||||
storage/events/archived/*
|
|
||||||
storage/thumbnails/*
|
|
||||||
data/*.db
|
data/*.db
|
||||||
logs/*
|
logs/*
|
||||||
coverage
|
coverage
|
||||||
|
|||||||
@@ -213,25 +213,6 @@ async function validateFileContent(filePath, expectedMimeType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get safe filename for storage
|
|
||||||
* @param {string} originalFilename - Original filename
|
|
||||||
* @returns {string} - Safe filename
|
|
||||||
*/
|
|
||||||
function getSafeFilename(originalFilename) {
|
|
||||||
const timestamp = Date.now();
|
|
||||||
const randomString = Math.random().toString(36).substring(2, 15);
|
|
||||||
const ext = path.extname(originalFilename).toLowerCase();
|
|
||||||
|
|
||||||
// Validate extension - including both image and video extensions
|
|
||||||
const validExtensions = ['.jpg', '.jpeg', '.png', '.webp', '.gif', '.svg', '.ico', '.mp4', '.m4v', '.webm', '.mov', '.avi'];
|
|
||||||
if (!validExtensions.includes(ext)) {
|
|
||||||
throw new Error('Invalid file extension');
|
|
||||||
}
|
|
||||||
|
|
||||||
return `upload_${timestamp}_${randomString}${ext}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a file upload validator middleware
|
* Create a file upload validator middleware
|
||||||
* @param {Object} options - Validation options
|
* @param {Object} options - Validation options
|
||||||
@@ -295,7 +276,6 @@ module.exports = {
|
|||||||
isPathSafe,
|
isPathSafe,
|
||||||
validateFileType,
|
validateFileType,
|
||||||
validateFileContent,
|
validateFileContent,
|
||||||
getSafeFilename,
|
|
||||||
createFileUploadValidator,
|
createFileUploadValidator,
|
||||||
ALLOWED_IMAGE_TYPES,
|
ALLOWED_IMAGE_TYPES,
|
||||||
ALLOWED_VIDEO_TYPES,
|
ALLOWED_VIDEO_TYPES,
|
||||||
|
|||||||
Reference in New Issue
Block a user