File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
classrooms/[classroomId]/upload Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff 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+
3335export 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 } ;
Original file line number Diff line number Diff 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 = { {
Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ const nextConfig: NextConfig = {
1313 } ,
1414 ] ,
1515 } ,
16+ experimental : {
17+ serverActions : {
18+ bodySizeLimit : "10mb" ,
19+ } ,
20+ } ,
1621} ;
1722
1823export default nextConfig ;
You can’t perform that action at this time.
0 commit comments