Skip to content

Commit

Permalink
Cast before checking
Browse files Browse the repository at this point in the history
  • Loading branch information
viral32111 authored and github-actions[bot] committed Nov 3, 2023
1 parent 4f51fe4 commit 9bd5c0c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Server/source/routes/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ expressApp.put( "/api/upload", ( request, response ) => {

// If we got to this point, then no errors occured

// Cast because TypeScript doesn't know how to do this automatically
const uploadedFiles = request.files as Express.Multer.File[] | undefined

// Fail if no files were uploaded
if ( request.files === undefined || request.files.length <= 0 ) return respondToRequest( response, HTTPStatusCodes.BadRequest, {
if ( uploadedFiles === undefined || uploadedFiles.length <= 0 ) return respondToRequest( response, HTTPStatusCodes.BadRequest, {
error: ErrorCodes.NoFilesUploaded
} )

// Cast because TypeScript doesn't know how to do this automatically
const uploadedFiles = request.files as Express.Multer.File[]

// Loop through the uploaded files & add their type and URL to a payload for the response
const filesPayload: Attachment[] = []
for ( const file of uploadedFiles ) filesPayload.push( {
Expand Down

0 comments on commit 9bd5c0c

Please sign in to comment.