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'
)
uploadRouter.post('/upload',
+ docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy'),
authenticate,
reqVideoFileAdd,
asyncMiddleware(videosAddLegacyValidator),
)
uploadRouter.post('/upload-resumable',
+ docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit'),
authenticate,
reqVideoFileAddResumable,
asyncMiddleware(videosAddResumableInitValidator),
)
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),
// 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]