updates
This commit is contained in:
parent
9af9977749
commit
4579b35fe0
|
|
@ -623,13 +623,15 @@ const downloadFile = async (file: FileItem) => {
|
||||||
// Check if Safari (iOS or desktop)
|
// Check if Safari (iOS or desktop)
|
||||||
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||||
|
|
||||||
|
const bucket = file.bucket || 'client-portal';
|
||||||
|
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
// For Safari, open in new window to force proper filename handling
|
// 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;
|
window.location.href = downloadUrl;
|
||||||
} else {
|
} else {
|
||||||
// For other browsers, use blob approach
|
// 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) {
|
if (!response.ok) {
|
||||||
throw new Error('Failed to download file');
|
throw new Error('Failed to download file');
|
||||||
|
|
@ -714,6 +716,7 @@ const deleteSelected = async () => {
|
||||||
body: {
|
body: {
|
||||||
fileName: item.name,
|
fileName: item.name,
|
||||||
isFolder: item.isFolder,
|
isFolder: item.isFolder,
|
||||||
|
bucket: item.bucket || 'client-portal',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
successCount++;
|
successCount++;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue