main #11

Merged
mstoeck3 merged 66 commits from main into forensic-ai 2025-08-11 12:02:56 +00:00
2 changed files with 72 additions and 25 deletions
Showing only changes of commit daa468c535 - Show all commits

View File

@ -21,8 +21,13 @@ 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',
@ -30,7 +35,32 @@ const UPLOAD_CONFIG = {
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'text/plain', 'text/csv', 'application/json'
// Text files
'text/plain',
'text/csv',
'text/markdown', // Added markdown
'text/x-markdown', // Alternative markdown MIME type
'application/json',
'application/xml',
'text/xml',
'text/html',
// Archives
'application/zip',
'application/x-tar',
'application/gzip',
'application/x-gzip',
'application/x-zip-compressed',
'application/x-rar-compressed',
'application/x-7z-compressed',
// Additional useful formats
'application/rtf', // Rich Text Format
'text/richtext',
'application/x-yaml', // YAML files
'text/yaml',
'application/yaml'
]),
localUploadPath: process.env.LOCAL_UPLOAD_PATH || './public/uploads',
publicBaseUrl: process.env.PUBLIC_BASE_URL || 'http://localhost:4321'

View File

@ -114,8 +114,13 @@ const sortedTools = data.tools.sort((a: any, b: any) => a.name.localeCompare(b.n
<div class="form-group">
<label class="form-label">Dokumente, Bilder, Videos (Optional)</label>
<div class="upload-area" id="upload-area">
<input type="file" id="file-input" multiple accept=".pdf,.doc,.docx,.txt,.md,.zip,.png,.jpg,.jpeg,.gif,.mp4,.webm" class="hidden">
<div class="upload-placeholder">
<input
type="file"
id="file-input"
multiple
accept=".pdf,.doc,.docx,.txt,.md,.markdown,.csv,.json,.xml,.html,.rtf,.yaml,.yml,.zip,.tar,.gz,.rar,.7z,.png,.jpg,.jpeg,.gif,.webp,.svg,.mp4,.webm,.mov,.avi"
class="hidden"
> <div class="upload-placeholder">
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="7 10 12 15 17 10"/>
@ -342,37 +347,49 @@ class KnowledgebaseForm {
console.log('[UPLOAD] Response status:', response.status);
console.log('[UPLOAD] Response headers:', Object.fromEntries(response.headers.entries()));
// FIXED: Read the response body only once
let responseData: any;
let responseText: string;
try {
// Try to read as text first (works for both JSON and plain text)
responseText = await response.text();
console.log('[UPLOAD] Raw response:', responseText.substring(0, 200));
// Then try to parse as JSON
try {
responseData = JSON.parse(responseText);
} catch (parseError) {
// If JSON parsing fails, treat as plain text
responseData = { error: responseText };
}
} catch (readError) {
console.error('[UPLOAD] Failed to read response:', readError);
throw new Error('Failed to read server response');
}
if (response.ok) {
const result = await response.json();
console.log('[UPLOAD] Success result:', result);
console.log('[UPLOAD] Success result:', responseData);
fileItem.uploaded = true;
fileItem.url = result.url;
fileItem.url = responseData.url;
this.renderFileList();
this.showMessage('success', `Successfully uploaded ${fileItem.name}`);
} else {
// Enhanced error handling - read the actual error from response
// Enhanced error handling with single response read
let errorMessage = `Upload failed with status ${response.status}`;
try {
const errorData = await response.json();
console.error('[UPLOAD] Error response data:', errorData);
if (errorData.error) {
errorMessage = errorData.error;
}
// Log additional details if available
if (errorData.details) {
console.error('[UPLOAD] Error details:', errorData.details);
errorMessage += ` (Details: ${errorData.details.join(', ')})`;
}
} catch (parseError) {
console.error('[UPLOAD] Could not parse error response:', parseError);
const errorText = await response.text();
console.error('[UPLOAD] Raw error response:', errorText);
errorMessage += ` (Raw: ${errorText.substring(0, 100)})`;
if (responseData && responseData.error) {
errorMessage = responseData.error;
} else if (responseText) {
errorMessage += ` (${responseText.substring(0, 100)})`;
}
// Log additional details if available
if (responseData && responseData.details) {
console.error('[UPLOAD] Error details:', responseData.details);
errorMessage += ` (Details: ${responseData.details.join(', ')})`;
}
throw new Error(errorMessage);