mirror of https://github.com/Chocobozzz/PeerTube
Fix 400 error on resumable re-upload
parent
926c3f2b37
commit
6bd160a68d
|
@ -1,8 +1,7 @@
|
||||||
import cors from 'cors'
|
import cors from 'cors'
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
|
import { logger } from '@server/helpers/logger'
|
||||||
import { HttpStatusCode } from '../../../shared/models'
|
import { HttpStatusCode } from '../../../shared/models'
|
||||||
import { badRequest } from '../../helpers/express-utils'
|
|
||||||
import { abuseRouter } from './abuse'
|
import { abuseRouter } from './abuse'
|
||||||
import { accountsRouter } from './accounts'
|
import { accountsRouter } from './accounts'
|
||||||
import { blocklistRouter } from './blocklist'
|
import { blocklistRouter } from './blocklist'
|
||||||
|
@ -64,3 +63,11 @@ export { apiRouter }
|
||||||
function pong (req: express.Request, res: express.Response) {
|
function pong (req: express.Request, res: express.Response) {
|
||||||
return res.send('pong').status(HttpStatusCode.OK_200).end()
|
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()
|
||||||
|
}
|
||||||
|
|
|
@ -63,13 +63,13 @@ uploadRouter.post('/upload-resumable',
|
||||||
authenticate,
|
authenticate,
|
||||||
reqVideoFileAddResumable,
|
reqVideoFileAddResumable,
|
||||||
asyncMiddleware(videosAddResumableInitValidator),
|
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',
|
uploadRouter.delete('/upload-resumable',
|
||||||
authenticate,
|
authenticate,
|
||||||
asyncMiddleware(deleteUploadResumableCache),
|
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',
|
uploadRouter.put('/upload-resumable',
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import express, { RequestHandler } from 'express'
|
import express, { RequestHandler } from 'express'
|
||||||
import multer, { diskStorage } from 'multer'
|
import multer, { diskStorage } from 'multer'
|
||||||
import { getLowercaseExtension } from '@shared/core-utils'
|
import { getLowercaseExtension } from '@shared/core-utils'
|
||||||
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
|
|
||||||
import { CONFIG } from '../initializers/config'
|
import { CONFIG } from '../initializers/config'
|
||||||
import { REMOTE_SCHEME } from '../initializers/constants'
|
import { REMOTE_SCHEME } from '../initializers/constants'
|
||||||
import { isArray } from './custom-validators/misc'
|
import { isArray } from './custom-validators/misc'
|
||||||
|
@ -59,12 +58,6 @@ function getHostWithPort (host: string) {
|
||||||
return host
|
return host
|
||||||
}
|
}
|
||||||
|
|
||||||
function badRequest (_req: express.Request, res: express.Response) {
|
|
||||||
return res.type('json')
|
|
||||||
.status(HttpStatusCode.BAD_REQUEST_400)
|
|
||||||
.end()
|
|
||||||
}
|
|
||||||
|
|
||||||
function createReqFiles (
|
function createReqFiles (
|
||||||
fieldNames: string[],
|
fieldNames: string[],
|
||||||
mimeTypes: { [id: string]: string | string[] },
|
mimeTypes: { [id: string]: string | string[] },
|
||||||
|
@ -126,7 +119,6 @@ export {
|
||||||
getHostWithPort,
|
getHostWithPort,
|
||||||
createAnyReqFiles,
|
createAnyReqFiles,
|
||||||
isUserAbleToSearchRemoteURI,
|
isUserAbleToSearchRemoteURI,
|
||||||
badRequest,
|
|
||||||
createReqFiles,
|
createReqFiles,
|
||||||
cleanUpReqFiles,
|
cleanUpReqFiles,
|
||||||
getCountVideos
|
getCountVideos
|
||||||
|
|
Loading…
Reference in New Issue