aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/upload.ts5
-rw-r--r--server/lib/uploadx.ts8
-rw-r--r--server/middlewares/validators/videos/videos.ts17
3 files changed, 7 insertions, 23 deletions
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 89787f20b..fd90d9915 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -40,8 +40,7 @@ import {
40 authenticate, 40 authenticate,
41 videosAddLegacyValidator, 41 videosAddLegacyValidator,
42 videosAddResumableInitValidator, 42 videosAddResumableInitValidator,
43 videosAddResumableValidator, 43 videosAddResumableValidator
44 videosResumableUploadIdValidator
45} from '../../../middlewares' 44} from '../../../middlewares'
46import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 45import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
47import { VideoModel } from '../../../models/video/video' 46import { VideoModel } from '../../../models/video/video'
@@ -88,7 +87,6 @@ uploadRouter.post('/upload-resumable',
88 87
89uploadRouter.delete('/upload-resumable', 88uploadRouter.delete('/upload-resumable',
90 authenticate, 89 authenticate,
91 videosResumableUploadIdValidator,
92 asyncMiddleware(deleteUploadResumableCache), 90 asyncMiddleware(deleteUploadResumableCache),
93 uploadx.upload 91 uploadx.upload
94) 92)
@@ -96,7 +94,6 @@ uploadRouter.delete('/upload-resumable',
96uploadRouter.put('/upload-resumable', 94uploadRouter.put('/upload-resumable',
97 openapiOperationDoc({ operationId: 'uploadResumable' }), 95 openapiOperationDoc({ operationId: 'uploadResumable' }),
98 authenticate, 96 authenticate,
99 videosResumableUploadIdValidator,
100 uploadx.upload, // uploadx doesn't next() before the file upload completes 97 uploadx.upload, // uploadx doesn't next() before the file upload completes
101 asyncMiddleware(videosAddResumableValidator), 98 asyncMiddleware(videosAddResumableValidator),
102 asyncMiddleware(addVideoResumable) 99 asyncMiddleware(addVideoResumable)
diff --git a/server/lib/uploadx.ts b/server/lib/uploadx.ts
index 36f5a556c..34a4461f0 100644
--- a/server/lib/uploadx.ts
+++ b/server/lib/uploadx.ts
@@ -5,9 +5,13 @@ import { Uploadx } from '@uploadx/core'
5const uploadx = new Uploadx({ 5const uploadx = new Uploadx({
6 directory: getResumableUploadPath(), 6 directory: getResumableUploadPath(),
7 // Could be big with thumbnails/previews 7 // Could be big with thumbnails/previews
8 maxMetadataSize: '10MB' 8 maxMetadataSize: '10MB',
9 userIdentifier: (_, res: express.Response) => {
10 if (!res.locals.oauth) return undefined
11
12 return res.locals.oauth.token.user.id + ''
13 }
9}) 14})
10uploadx.getUserId = (_, res: express.Response) => res.locals.oauth?.token.user.id
11 15
12export { 16export {
13 uploadx 17 uploadx
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 3a1a905f3..b3ffb7007 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -102,22 +102,6 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
102 } 102 }
103]) 103])
104 104
105const videosResumableUploadIdValidator = [
106 (req: express.Request, res: express.Response, next: express.NextFunction) => {
107 const user = res.locals.oauth.token.User
108 const uploadId = req.query.upload_id
109
110 if (uploadId.startsWith(user.id + '-') !== true) {
111 return res.fail({
112 status: HttpStatusCode.FORBIDDEN_403,
113 message: 'You cannot send chunks in another user upload'
114 })
115 }
116
117 return next()
118 }
119]
120
121/** 105/**
122 * Gets called after the last PUT request 106 * Gets called after the last PUT request
123 */ 107 */
@@ -566,7 +550,6 @@ export {
566 videosAddLegacyValidator, 550 videosAddLegacyValidator,
567 videosAddResumableValidator, 551 videosAddResumableValidator,
568 videosAddResumableInitValidator, 552 videosAddResumableInitValidator,
569 videosResumableUploadIdValidator,
570 553
571 videosUpdateValidator, 554 videosUpdateValidator,
572 videosGetValidator, 555 videosGetValidator,