Refactor file handling to prioritize internal data directories for backups and uploads; enhance error handling and logging for metadata and CSV operations.
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 47s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 47s
This commit is contained in:
@@ -26,9 +26,12 @@ const getDataPath = (filename) => {
|
||||
}
|
||||
|
||||
// Multer-Konfiguration für PDF-Uploads
|
||||
// Store uploads in internal data directory instead of public/
|
||||
const DOCUMENTS_DIR = getDataPath('documents')
|
||||
|
||||
const storage = multer.diskStorage({
|
||||
destination: (req, file, cb) => {
|
||||
cb(null, 'public/documents/')
|
||||
cb(null, DOCUMENTS_DIR)
|
||||
},
|
||||
filename: (req, file, cb) => {
|
||||
cb(null, 'satzung.pdf')
|
||||
@@ -74,8 +77,9 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.mkdir(path.join(process.cwd(), 'public', 'documents'), { recursive: true })
|
||||
try {
|
||||
// Ensure internal documents dir exists
|
||||
await fs.mkdir(DOCUMENTS_DIR, { recursive: true })
|
||||
|
||||
// Multer-Middleware für File-Upload
|
||||
await new Promise((resolve, reject) => {
|
||||
@@ -133,8 +137,9 @@ export default defineEventHandler(async (event) => {
|
||||
configData.seiten = {}
|
||||
}
|
||||
|
||||
// Serve the uploaded statute via internal media proxy
|
||||
configData.seiten.satzung = {
|
||||
pdfUrl: '/documents/satzung.pdf',
|
||||
pdfUrl: '/api/media/documents/satzung.pdf',
|
||||
content: htmlContent
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user