Skip to content

Commit 25c96b5

Browse files
authored
DEVT67 - changed limit, added file size warning (#60)
1 parent 2171ae2 commit 25c96b5

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

app/classrooms/[classroomId]/upload/uploadComponent.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ type UploadedFile = {
3030
status: string;
3131
};
3232

33+
const ACTION_MAX_SIZE_BYTES = 10 * 1_000_000; // this is set in next.config.ts
34+
3335
export default function UploadComponent({
3436
classroomId,
3537
classroomName,
@@ -75,6 +77,14 @@ export default function UploadComponent({
7577

7678
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {
7779
if (e.target.files && e.target.files.length > 0) {
80+
if (e.target.files[0].size > ACTION_MAX_SIZE_BYTES) {
81+
toast.error("File size too big!");
82+
e.preventDefault();
83+
if (inputFile.current) {
84+
inputFile.current.value = "";
85+
}
86+
return;
87+
}
7888
setFile(e.target.files[0]);
7989
}
8090
};

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default async function RootLayout({
6060
<Toaster
6161
// richColors
6262
duration={40000}
63-
expand
63+
// expand
6464
// richColors
6565
closeButton
6666
toastOptions={{

next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const nextConfig: NextConfig = {
1313
},
1414
],
1515
},
16+
experimental: {
17+
serverActions: {
18+
bodySizeLimit: "10mb",
19+
},
20+
},
1621
};
1722

1823
export default nextConfig;

0 commit comments

Comments
 (0)