]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/upload.ts
Fix CLI build
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / upload.ts
index ebc17c7609a79c124589f813a7e567c1fc888362..93a68f759d03425f6e31091f56d3a80f267bd61c 100644 (file)
@@ -6,6 +6,7 @@ import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
 import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
 import { addOptimizeOrMergeAudioJob, buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
 import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
+import { docMiddleware } from '@server/middlewares/doc'
 import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
 import { uploadx } from '@uploadx/core'
 import { VideoCreate, VideoState } from '../../../../shared'
@@ -60,6 +61,7 @@ const reqVideoFileAddResumable = createReqFiles(
 )
 
 uploadRouter.post('/upload',
+  docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy'),
   authenticate,
   reqVideoFileAdd,
   asyncMiddleware(videosAddLegacyValidator),
@@ -67,6 +69,7 @@ uploadRouter.post('/upload',
 )
 
 uploadRouter.post('/upload-resumable',
+  docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit'),
   authenticate,
   reqVideoFileAddResumable,
   asyncMiddleware(videosAddResumableInitValidator),
@@ -79,6 +82,7 @@ uploadRouter.delete('/upload-resumable',
 )
 
 uploadRouter.put('/upload-resumable',
+  docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumable'),
   authenticate,
   uploadxMiddleware, // uploadx doesn't use call next() before the file upload completes
   asyncMiddleware(videosAddResumableValidator),
@@ -97,8 +101,11 @@ export async function addVideoLegacy (req: express.Request, res: express.Respons
   // Uploading the video could be long
   // Set timeout to 10 minutes, as Express's default is 2 minutes
   req.setTimeout(1000 * 60 * 10, () => {
-    logger.error('Upload video has timed out.')
-    return res.sendStatus(HttpStatusCode.REQUEST_TIMEOUT_408)
+    logger.error('Video upload has timed out.')
+    return res.fail({
+      status: HttpStatusCode.REQUEST_TIMEOUT_408,
+      message: 'Video upload has timed out.'
+    })
   })
 
   const videoPhysicalFile = req.files['videofile'][0]