Skip to content

Commit 536ca79

Browse files
committed
Support unidentified file formats with a download link
1 parent 29402bc commit 536ca79

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/components/file-display.tsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
function FileDisplay({ src, type }: { src: string; type: string }) {
1+
import { Button } from "@/components/ui/button";
2+
3+
function FileDisplay({
4+
src,
5+
type,
6+
ext,
7+
}: {
8+
src: string;
9+
type: string;
10+
ext: string;
11+
}) {
212
const [fileType] = type.split("/");
313
const props = { src, className: "max-w-screen-sm" };
414

@@ -12,6 +22,14 @@ function FileDisplay({ src, type }: { src: string; type: string }) {
1222
case "audio":
1323
return <audio {...props} controls />;
1424
break;
25+
default:
26+
return (
27+
<Button variant="link">
28+
<a href={src} download={`file.${ext}`}>
29+
Not sure how to render click to download
30+
</a>
31+
</Button>
32+
);
1533
}
1634
}
1735

0 commit comments

Comments
 (0)