File tree Expand file tree Collapse file tree
app/api/workspaces/[id]/files/presigned Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,14 +46,6 @@ export const POST = withRouteHandler(
4646 )
4747 }
4848
49- const quotaCheck = await checkStorageQuota ( userId , fileSize )
50- if ( ! quotaCheck . allowed ) {
51- return NextResponse . json (
52- { error : quotaCheck . error || 'Storage limit exceeded' } ,
53- { status : 413 }
54- )
55- }
56-
5749 if ( ! hasCloudStorage ( ) ) {
5850 logger . info ( `Local storage detected, signaling API fallback for ${ fileName } ` )
5951 return NextResponse . json ( {
@@ -64,6 +56,14 @@ export const POST = withRouteHandler(
6456 } )
6557 }
6658
59+ const quotaCheck = await checkStorageQuota ( userId , fileSize )
60+ if ( ! quotaCheck . allowed ) {
61+ return NextResponse . json (
62+ { error : quotaCheck . error || 'Storage limit exceeded' } ,
63+ { status : 413 }
64+ )
65+ }
66+
6767 const key = generateWorkspaceFileKey ( workspaceId , fileName )
6868 const presigned = await generatePresignedUploadUrl ( {
6969 fileName,
Original file line number Diff line number Diff line change @@ -180,8 +180,15 @@ export const getPresignedUploadInfo = async (
180180 try {
181181 errorDetails = await response . json ( )
182182 } catch { }
183+ const serverMessage =
184+ errorDetails != null &&
185+ typeof errorDetails === 'object' &&
186+ typeof ( errorDetails as Record < string , unknown > ) . error === 'string'
187+ ? ( ( errorDetails as Record < string , unknown > ) . error as string )
188+ : null
183189 throw new DirectUploadError (
184- `Failed to get presigned URL for ${ file . name } : ${ response . status } ${ response . statusText } ` ,
190+ serverMessage ||
191+ `Failed to get presigned URL for ${ file . name } : ${ response . status } ${ response . statusText } ` ,
185192 'PRESIGNED_URL_ERROR' ,
186193 errorDetails
187194 )
You can’t perform that action at this time.
0 commit comments