diff options
Diffstat (limited to 'server/controllers/api/videos/upload.ts')
-rw-r--r-- | server/controllers/api/videos/upload.ts | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index 55cb9cf20..02aadd426 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts | |||
@@ -7,6 +7,7 @@ import { uuidToShort } from '@server/helpers/uuid' | |||
7 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 7 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
8 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' | 8 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
9 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' | 9 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' |
10 | import { Redis } from '@server/lib/redis' | ||
10 | import { | 11 | import { |
11 | addMoveToObjectStorageJob, | 12 | addMoveToObjectStorageJob, |
12 | addOptimizeOrMergeAudioJob, | 13 | addOptimizeOrMergeAudioJob, |
@@ -94,7 +95,7 @@ uploadRouter.delete('/upload-resumable', | |||
94 | uploadRouter.put('/upload-resumable', | 95 | uploadRouter.put('/upload-resumable', |
95 | openapiOperationDoc({ operationId: 'uploadResumable' }), | 96 | openapiOperationDoc({ operationId: 'uploadResumable' }), |
96 | authenticate, | 97 | authenticate, |
97 | uploadxMiddleware, // uploadx doesn't use call next() before the file upload completes | 98 | uploadxMiddleware, // uploadx doesn't next() before the file upload completes |
98 | asyncMiddleware(videosAddResumableValidator), | 99 | asyncMiddleware(videosAddResumableValidator), |
99 | asyncMiddleware(addVideoResumable) | 100 | asyncMiddleware(addVideoResumable) |
100 | ) | 101 | ) |
@@ -122,15 +123,20 @@ export async function addVideoLegacy (req: express.Request, res: express.Respons | |||
122 | const videoInfo: VideoCreate = req.body | 123 | const videoInfo: VideoCreate = req.body |
123 | const files = req.files | 124 | const files = req.files |
124 | 125 | ||
125 | return addVideo({ res, videoPhysicalFile, videoInfo, files }) | 126 | const response = await addVideo({ res, videoPhysicalFile, videoInfo, files }) |
127 | |||
128 | return res.json(response) | ||
126 | } | 129 | } |
127 | 130 | ||
128 | export async function addVideoResumable (_req: express.Request, res: express.Response) { | 131 | export async function addVideoResumable (req: express.Request, res: express.Response) { |
129 | const videoPhysicalFile = res.locals.videoFileResumable | 132 | const videoPhysicalFile = res.locals.videoFileResumable |
130 | const videoInfo = videoPhysicalFile.metadata | 133 | const videoInfo = videoPhysicalFile.metadata |
131 | const files = { previewfile: videoInfo.previewfile } | 134 | const files = { previewfile: videoInfo.previewfile } |
132 | 135 | ||
133 | return addVideo({ res, videoPhysicalFile, videoInfo, files }) | 136 | const response = await addVideo({ res, videoPhysicalFile, videoInfo, files }) |
137 | await Redis.Instance.setUploadSession(req.query.upload_id, response) | ||
138 | |||
139 | return res.json(response) | ||
134 | } | 140 | } |
135 | 141 | ||
136 | async function addVideo (options: { | 142 | async function addVideo (options: { |
@@ -225,13 +231,13 @@ async function addVideo (options: { | |||
225 | 231 | ||
226 | Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) | 232 | Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) |
227 | 233 | ||
228 | return res.json({ | 234 | return { |
229 | video: { | 235 | video: { |
230 | id: videoCreated.id, | 236 | id: videoCreated.id, |
231 | shortUUID: uuidToShort(videoCreated.uuid), | 237 | shortUUID: uuidToShort(videoCreated.uuid), |
232 | uuid: videoCreated.uuid | 238 | uuid: videoCreated.uuid |
233 | } | 239 | } |
234 | }) | 240 | } |
235 | } | 241 | } |
236 | 242 | ||
237 | async function buildNewFile (videoPhysicalFile: express.VideoUploadFile) { | 243 | async function buildNewFile (videoPhysicalFile: express.VideoUploadFile) { |