'use client'; import React from 'react'; import { cn } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { Download, File, Loader } from 'lucide-react'; interface BinaryRendererProps { url: string; fileName: string; className?: string; onDownload?: () => void; isDownloading?: boolean; } export function BinaryRenderer({ url, fileName, className, onDownload, isDownloading = false, }: BinaryRendererProps) { const fileExtension = fileName.split('.').pop()?.toLowerCase() || ''; // Handle download - use external handler if provided, fallback to direct URL const handleDownload = () => { if (onDownload) { // Use the file-viewer's more robust download handler if provided onDownload(); } else if (url) { // Fallback to direct URL download (less robust) console.log(`[BINARY RENDERER] Using fallback download for ${fileName}`); const link = document.createElement('a'); link.href = url; link.download = fileName.split('/').pop() || 'file'; document.body.appendChild(link); link.click(); document.body.removeChild(link); } else { console.error('[BINARY RENDERER] No download URL or handler available'); } }; return (
{fileExtension.toUpperCase()}

{fileName.split('/').pop()}

This binary file cannot be previewed in the browser

); }