Skip to content

Commit 130b08f

Browse files
committed
Display an Upload Button
1 parent 70644c7 commit 130b08f

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/app/api/uploadthing/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createRouteHandler } from "uploadthing/next";
2+
3+
import { ourFileRouter } from "./core";
4+
5+
// Export routes for Next App Router
6+
export const { GET, POST } = createRouteHandler({
7+
router: ourFileRouter,
8+
});

src/app/drive-contents.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { SignedIn, SignedOut, SignInButton, UserButton } from "@clerk/nextjs";
44
import { ChevronRight } from "lucide-react";
55
import Link from "next/link";
66

7+
import { UploadButton } from "~/components/uploadthing";
78
import type { File, Folder } from "~/server/db/schema";
89
import { FileRow, FolderRow } from "./file-row";
10+
import { UploadButton } from "~/components/uploadthing";
911

1012
export default function DriveContents(props: {
1113
files: File[];
@@ -59,6 +61,7 @@ export default function DriveContents(props: {
5961
))}
6062
</ul>
6163
</div>
64+
<UploadButton endpoint="imageUploader" />
6265
</div>
6366
</div>
6467
);

src/components/uploadthing.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { generateUploadButton } from "@uploadthing/react";
2+
3+
import type { OurFileRouter } from "~/app/api/uploadthing/core";
4+
5+
export const UploadButton = generateUploadButton<OurFileRouter>();

src/styles/globals.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
@import "tailwindcss";
22
@import "tw-animate-css";
33

4+
@import "uploadthing/tw/v4";
5+
@source "../../node_modules/@uploadthing/react/dist"; /** <-- depends on project structure */
6+
47
@custom-variant dark (&:is(.dark *));
58

69
@theme {
7-
--font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif,
10+
--font-sans:
11+
var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif,
812
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
913
}
1014

0 commit comments

Comments
 (0)