This commit is contained in:
Matt 2025-06-10 15:33:01 +02:00
parent 9af9977749
commit 4579b35fe0
2 changed files with 64 additions and 2 deletions

View File

@ -623,13 +623,15 @@ const downloadFile = async (file: FileItem) => {
// Check if Safari (iOS or desktop)
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
const bucket = file.bucket || 'client-portal';
if (isSafari) {
// For Safari, open in new window to force proper filename handling
const downloadUrl = `/api/files/proxy-download?fileName=${encodeURIComponent(file.name)}`;
const downloadUrl = `/api/files/proxy-download?fileName=${encodeURIComponent(file.name)}&bucket=${bucket}`;
window.location.href = downloadUrl;
} else {
// For other browsers, use blob approach
const response = await fetch(`/api/files/proxy-download?fileName=${encodeURIComponent(file.name)}`);
const response = await fetch(`/api/files/proxy-download?fileName=${encodeURIComponent(file.name)}&bucket=${bucket}`);
if (!response.ok) {
throw new Error('Failed to download file');
@ -714,6 +716,7 @@ const deleteSelected = async () => {
body: {
fileName: item.name,
isFolder: item.isFolder,
bucket: item.bucket || 'client-portal',
},
});
successCount++;

View File

@ -0,0 +1,59 @@
export default defineEventHandler(async (event) => {
try {
const { fileName, bucket } = getQuery(event);
if (!fileName || !bucket) {
return {
success: false,
error: 'Missing fileName or bucket parameter'
};
}
console.log('[test-delete] Attempting to delete:', {
fileName: fileName as string,
bucket: bucket as string
});
// Import MinIO client
const { getMinioClient } = await import('~/server/utils/minio');
const client = getMinioClient();
// Check if file exists first
try {
const stat = await client.statObject(bucket as string, fileName as string);
console.log('[test-delete] File exists:', stat);
} catch (error: any) {
console.error('[test-delete] File not found:', error.message);
return {
success: false,
error: 'File not found in bucket',
details: error.message
};
}
// Try to delete the file
try {
await client.removeObject(bucket as string, fileName as string);
console.log('[test-delete] File deleted successfully');
return {
success: true,
message: 'File deleted successfully'
};
} catch (error: any) {
console.error('[test-delete] Delete failed:', error);
return {
success: false,
error: 'Failed to delete file',
details: error.message
};
}
} catch (error: any) {
console.error('[test-delete] Unexpected error:', error);
return {
success: false,
error: 'Unexpected error',
details: error.message
};
}
});