From 6bd160a68dac55f61b28c7631f9985320daf7755 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 29 Jun 2023 11:35:25 +0200 Subject: Fix 400 error on resumable re-upload --- server/controllers/api/index.ts | 11 +++++++++-- server/controllers/api/videos/upload.ts | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts index 31f1a56f9..38bd135d0 100644 --- a/server/controllers/api/index.ts +++ b/server/controllers/api/index.ts @@ -1,8 +1,7 @@ import cors from 'cors' import express from 'express' - +import { logger } from '@server/helpers/logger' import { HttpStatusCode } from '../../../shared/models' -import { badRequest } from '../../helpers/express-utils' import { abuseRouter } from './abuse' import { accountsRouter } from './accounts' import { blocklistRouter } from './blocklist' @@ -64,3 +63,11 @@ export { apiRouter } function pong (req: express.Request, res: express.Response) { return res.send('pong').status(HttpStatusCode.OK_200).end() } + +function badRequest (req: express.Request, res: express.Response) { + logger.debug(`API express handler not found: bad PeerTube request for ${req.method} - ${req.originalUrl}`) + + return res.type('json') + .status(HttpStatusCode.BAD_REQUEST_400) + .end() +} diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index 0e07302d2..27fef0b1a 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts @@ -63,13 +63,13 @@ uploadRouter.post('/upload-resumable', authenticate, reqVideoFileAddResumable, asyncMiddleware(videosAddResumableInitValidator), - uploadx.upload + (req, res) => uploadx.upload(req, res) // Prevent next() call, explicitely tell to uploadx it's the end ) uploadRouter.delete('/upload-resumable', authenticate, asyncMiddleware(deleteUploadResumableCache), - uploadx.upload + (req, res) => uploadx.upload(req, res) // Prevent next() call, explicitely tell to uploadx it's the end ) uploadRouter.put('/upload-resumable', -- cgit v1.2.3