-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bab462
commit 0f134d5
Showing
9 changed files
with
1,195 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createNextPageApiHandler } from "uploadthing/next-legacy"; | ||
|
||
import { ourFileRouter } from "../../server/uploadthing"; | ||
|
||
const handler = createNextPageApiHandler({ | ||
router: ourFileRouter, | ||
}); | ||
|
||
export default handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** server/uploadthing.ts */ | ||
import { createUploadthing, type FileRouter } from "uploadthing/next-legacy"; | ||
|
||
const f = createUploadthing(); | ||
|
||
// FileRouter for your app, can contain multiple FileRoutes | ||
export const ourFileRouter = { | ||
// Define as many FileRoutes as you like, each with a unique routeSlug | ||
imageUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 10 } }) | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
.onUploadComplete(async ({ file }) => { | ||
// This code RUNS ON YOUR SERVER after upload | ||
|
||
console.log("file url", file.url); | ||
}), | ||
} satisfies FileRouter; | ||
|
||
export type OurFileRouter = typeof ourFileRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { create } from "zustand"; | ||
|
||
interface SurauState { | ||
imageUploadLoading: boolean; | ||
setImageUploadLoading: (value: boolean) => void; | ||
} | ||
|
||
const useSurauStore = create<SurauState>((set) => ({ | ||
imageUploadLoading: false, | ||
setImageUploadLoading: (value: boolean) => set({ imageUploadLoading: value }), | ||
})); | ||
|
||
export default useSurauStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { generateComponents } from "@uploadthing/react"; | ||
|
||
import type { OurFileRouter } from "../server/uploadthing"; | ||
|
||
export const { UploadButton, UploadDropzone, Uploader } = | ||
generateComponents<OurFileRouter>(); |
Oops, something went wrong.