Add support for __dirname in ES modules by importing dirname and fileURLToPath. This change enables correct path resolution for file uploads, enhancing the image upload functionality.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync } from 'fs';
|
import { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join, dirname } from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
import { parse } from 'csv-parse/sync';
|
import { parse } from 'csv-parse/sync';
|
||||||
import multer from 'multer';
|
import multer from 'multer';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
@@ -7,6 +8,10 @@ import crypto from 'crypto';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { getSessionStatus, getClientsMap, getSessionIdForSocket } from './broadcast.js';
|
import { getSessionStatus, getClientsMap, getSessionIdForSocket } from './broadcast.js';
|
||||||
|
|
||||||
|
// __dirname für ES-Module
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
// Bild-Upload-Konfiguration (temporäres Verzeichnis)
|
// Bild-Upload-Konfiguration (temporäres Verzeichnis)
|
||||||
const uploadsDir = join(__dirname, '../tmp');
|
const uploadsDir = join(__dirname, '../tmp');
|
||||||
if (!existsSync(uploadsDir)) {
|
if (!existsSync(uploadsDir)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user