diff options
author | Chocobozzz <me@florianbigard.com> | 2023-06-29 11:35:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-06-29 11:35:25 +0200 |
commit | 6bd160a68dac55f61b28c7631f9985320daf7755 (patch) | |
tree | 8fa98847ef4e374f37a072a91e1eb804001b5fc7 /server/controllers/api | |
parent | 926c3f2b377196af1e8c5725aa54b8077cb79061 (diff) | |
download | PeerTube-6bd160a68dac55f61b28c7631f9985320daf7755.tar.gz PeerTube-6bd160a68dac55f61b28c7631f9985320daf7755.tar.zst PeerTube-6bd160a68dac55f61b28c7631f9985320daf7755.zip |
Fix 400 error on resumable re-upload
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/index.ts | 11 | ||||
-rw-r--r-- | server/controllers/api/videos/upload.ts | 4 |
2 files changed, 11 insertions, 4 deletions
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 @@ | |||
1 | import cors from 'cors' | 1 | import cors from 'cors' |
2 | import express from 'express' | 2 | import express from 'express' |
3 | 3 | import { logger } from '@server/helpers/logger' | |
4 | import { HttpStatusCode } from '../../../shared/models' | 4 | import { HttpStatusCode } from '../../../shared/models' |
5 | import { badRequest } from '../../helpers/express-utils' | ||
6 | import { abuseRouter } from './abuse' | 5 | import { abuseRouter } from './abuse' |
7 | import { accountsRouter } from './accounts' | 6 | import { accountsRouter } from './accounts' |
8 | import { blocklistRouter } from './blocklist' | 7 | import { blocklistRouter } from './blocklist' |
@@ -64,3 +63,11 @@ export { apiRouter } | |||
64 | function pong (req: express.Request, res: express.Response) { | 63 | function pong (req: express.Request, res: express.Response) { |
65 | return res.send('pong').status(HttpStatusCode.OK_200).end() | 64 | return res.send('pong').status(HttpStatusCode.OK_200).end() |
66 | } | 65 | } |
66 | |||
67 | function badRequest (req: express.Request, res: express.Response) { | ||
68 | logger.debug(`API express handler not found: bad PeerTube request for ${req.method} - ${req.originalUrl}`) | ||
69 | |||
70 | return res.type('json') | ||
71 | .status(HttpStatusCode.BAD_REQUEST_400) | ||
72 | .end() | ||
73 | } | ||
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', | |||
63 | authenticate, | 63 | authenticate, |
64 | reqVideoFileAddResumable, | 64 | reqVideoFileAddResumable, |
65 | asyncMiddleware(videosAddResumableInitValidator), | 65 | asyncMiddleware(videosAddResumableInitValidator), |
66 | uploadx.upload | 66 | (req, res) => uploadx.upload(req, res) // Prevent next() call, explicitely tell to uploadx it's the end |
67 | ) | 67 | ) |
68 | 68 | ||
69 | uploadRouter.delete('/upload-resumable', | 69 | uploadRouter.delete('/upload-resumable', |
70 | authenticate, | 70 | authenticate, |
71 | asyncMiddleware(deleteUploadResumableCache), | 71 | asyncMiddleware(deleteUploadResumableCache), |
72 | uploadx.upload | 72 | (req, res) => uploadx.upload(req, res) // Prevent next() call, explicitely tell to uploadx it's the end |
73 | ) | 73 | ) |
74 | 74 | ||
75 | uploadRouter.put('/upload-resumable', | 75 | uploadRouter.put('/upload-resumable', |