Basic version of eventmedia-management (upload,
save in database)
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
@import "../node_modules/@syncfusion/ej2-react-filemanager/styles/material.css";
|
|
||||||
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
|
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
|
||||||
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
|
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
|
||||||
@import "../node_modules/@syncfusion/ej2-calendars/styles/material.css";
|
@import "../node_modules/@syncfusion/ej2-calendars/styles/material.css";
|
||||||
@@ -11,6 +10,10 @@
|
|||||||
@import "../node_modules/@syncfusion/ej2-react-schedule/styles/material.css";
|
@import "../node_modules/@syncfusion/ej2-react-schedule/styles/material.css";
|
||||||
@import "../node_modules/@syncfusion/ej2-kanban/styles/material.css";
|
@import "../node_modules/@syncfusion/ej2-kanban/styles/material.css";
|
||||||
@import "../node_modules/@syncfusion/ej2-notifications/styles/material.css";
|
@import "../node_modules/@syncfusion/ej2-notifications/styles/material.css";
|
||||||
|
@import "../node_modules/@syncfusion/ej2-react-filemanager/styles/material.css";
|
||||||
|
@import "../node_modules/@syncfusion/ej2-layouts/styles/material.css";
|
||||||
|
@import "../node_modules/@syncfusion/ej2-grids/styles/material.css";
|
||||||
|
@import "../node_modules/@syncfusion/ej2-icons/styles/material.css";
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: Inter, 'Segoe UI', Roboto, Arial, sans-serif;
|
font-family: Inter, 'Segoe UI', Roboto, Arial, sans-serif;
|
||||||
|
|||||||
@@ -72,4 +72,4 @@ button:focus-visible {
|
|||||||
button {
|
button {
|
||||||
background-color: #f9f9f9;
|
background-color: #f9f9f9;
|
||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
|
|||||||
@@ -29,16 +29,6 @@ const Media: React.FC = () => {
|
|||||||
.then(setMediaList);
|
.then(setMediaList);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Upload-Handler (vereinfachtes Beispiel)
|
|
||||||
const handleUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
if (!e.target.files?.length) return;
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('file', e.target.files[0]);
|
|
||||||
await fetch('/api/eventmedia/upload', { method: 'POST', body: formData });
|
|
||||||
// Nach Upload neu laden
|
|
||||||
const res = await fetch('/api/eventmedia');
|
|
||||||
setMediaList(await res.json());
|
|
||||||
};
|
|
||||||
|
|
||||||
// Speichern von Metadaten/Event-Zuordnung
|
// Speichern von Metadaten/Event-Zuordnung
|
||||||
const handleSave = async (data: { title: string; description: string; eventId?: string }) => {
|
const handleSave = async (data: { title: string; description: string; eventId?: string }) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from re import A
|
from re import A
|
||||||
from flask import Blueprint, request, jsonify, send_from_directory
|
from flask import Blueprint, request, jsonify, send_from_directory
|
||||||
from database import Session
|
from database import Session
|
||||||
from models import EventMedia
|
from models import EventMedia, MediaType
|
||||||
import os
|
import os
|
||||||
|
|
||||||
eventmedia_bp = Blueprint('eventmedia', __name__, url_prefix='/api/eventmedia')
|
eventmedia_bp = Blueprint('eventmedia', __name__, url_prefix='/api/eventmedia')
|
||||||
@@ -75,11 +75,26 @@ def filemanager_operations():
|
|||||||
|
|
||||||
@eventmedia_bp.route('/filemanager/upload', methods=['POST'])
|
@eventmedia_bp.route('/filemanager/upload', methods=['POST'])
|
||||||
def filemanager_upload():
|
def filemanager_upload():
|
||||||
path = request.args.get('path', '/')
|
session = Session()
|
||||||
|
# Korrigiert: Erst aus request.form, dann aus request.args lesen
|
||||||
|
path = request.form.get('path') or request.args.get('path', '/')
|
||||||
upload_path = os.path.join(MEDIA_ROOT, path.lstrip('/'))
|
upload_path = os.path.join(MEDIA_ROOT, path.lstrip('/'))
|
||||||
os.makedirs(upload_path, exist_ok=True)
|
os.makedirs(upload_path, exist_ok=True)
|
||||||
for file in request.files.getlist('uploadFiles'):
|
for file in request.files.getlist('uploadFiles'):
|
||||||
file.save(os.path.join(upload_path, file.filename))
|
file_path = os.path.join(upload_path, file.filename)
|
||||||
|
file.save(file_path)
|
||||||
|
ext = os.path.splitext(file.filename)[1][1:].lower()
|
||||||
|
try:
|
||||||
|
media_type = MediaType(ext)
|
||||||
|
except ValueError:
|
||||||
|
media_type = MediaType.other
|
||||||
|
media = EventMedia(
|
||||||
|
media_type=media_type,
|
||||||
|
url=file.filename,
|
||||||
|
file_path=os.path.relpath(file_path, MEDIA_ROOT)
|
||||||
|
)
|
||||||
|
session.add(media)
|
||||||
|
session.commit()
|
||||||
return jsonify({'success': True})
|
return jsonify({'success': True})
|
||||||
|
|
||||||
# --- FileManager: Download ---
|
# --- FileManager: Download ---
|
||||||
|
|||||||
Reference in New Issue
Block a user