This commit is contained in:
overcuriousity
2025-08-09 22:48:29 +02:00
parent b8311e152d
commit b1c31379b2
5 changed files with 5 additions and 25 deletions

View File

@@ -1,4 +1,3 @@
// src/pages/api/upload/media.ts - Enhanced with detailed logging and error handling
import type { APIRoute } from 'astro';
import { withAPIAuth } from '../../../utils/auth.js';
import { apiResponse, apiError, apiServerError, apiSpecial, handleAPIRequest } from '../../../utils/api.js';
@@ -21,13 +20,10 @@ interface UploadResult {
const UPLOAD_CONFIG = {
maxFileSize: 50 * 1024 * 1024, // 50MB
allowedTypes: new Set([
// Images
'image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp', 'image/svg+xml',
// Videos
'video/mp4', 'video/webm', 'video/ogg', 'video/avi', 'video/mov',
// Documents
'application/pdf',
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
@@ -36,17 +32,15 @@ const UPLOAD_CONFIG = {
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
// Text files
'text/plain',
'text/csv',
'text/markdown', // Added markdown
'text/x-markdown', // Alternative markdown MIME type
'text/markdown',
'text/x-markdown',
'application/json',
'application/xml',
'text/xml',
'text/html',
// Archives
'application/zip',
'application/x-tar',
'application/gzip',
@@ -55,10 +49,9 @@ const UPLOAD_CONFIG = {
'application/x-rar-compressed',
'application/x-7z-compressed',
// Additional useful formats
'application/rtf', // Rich Text Format
'application/rtf',
'text/richtext',
'application/x-yaml', // YAML files
'application/x-yaml',
'text/yaml',
'application/yaml'
]),
@@ -185,7 +178,6 @@ export const POST: APIRoute = async ({ request }) => {
return await handleAPIRequest(async () => {
console.log('[UPLOAD] Processing upload request');
// Enhanced auth logging
const authResult = await withAPIAuth(request, 'contributions');
console.log('[UPLOAD] Auth result:', {
authenticated: authResult.authenticated,
@@ -230,7 +222,6 @@ export const POST: APIRoute = async ({ request }) => {
return apiError.badRequest(validation.error!);
}
// Enhanced environment logging
const nextcloudConfigured = isNextcloudConfigured();
console.log('[UPLOAD] Environment check:', {
nextcloudConfigured,