mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
server/server -> server/core
This commit is contained in:
parent
114327d4ce
commit
5a3d0650c9
838 changed files with 111 additions and 111 deletions
60
server/core/controllers/object-storage-proxy.ts
Normal file
60
server/core/controllers/object-storage-proxy.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { OBJECT_STORAGE_PROXY_PATHS } from '@server/initializers/constants.js'
|
||||
import { proxifyHLS, proxifyWebVideoFile } from '@server/lib/object-storage/index.js'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
ensureCanAccessPrivateVideoHLSFiles,
|
||||
ensureCanAccessVideoPrivateWebVideoFiles,
|
||||
ensurePrivateObjectStorageProxyIsEnabled,
|
||||
optionalAuthenticate
|
||||
} from '@server/middlewares/index.js'
|
||||
import { doReinjectVideoFileToken } from './shared/m3u8-playlist.js'
|
||||
|
||||
const objectStorageProxyRouter = express.Router()
|
||||
|
||||
objectStorageProxyRouter.use(cors())
|
||||
|
||||
objectStorageProxyRouter.get(
|
||||
[ OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEB_VIDEOS + ':filename', OBJECT_STORAGE_PROXY_PATHS.LEGACY_PRIVATE_WEB_VIDEOS + ':filename' ],
|
||||
ensurePrivateObjectStorageProxyIsEnabled,
|
||||
optionalAuthenticate,
|
||||
asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles),
|
||||
asyncMiddleware(proxifyWebVideoController)
|
||||
)
|
||||
|
||||
objectStorageProxyRouter.get(OBJECT_STORAGE_PROXY_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS + ':videoUUID/:filename',
|
||||
ensurePrivateObjectStorageProxyIsEnabled,
|
||||
optionalAuthenticate,
|
||||
asyncMiddleware(ensureCanAccessPrivateVideoHLSFiles),
|
||||
asyncMiddleware(proxifyHLSController)
|
||||
)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
objectStorageProxyRouter
|
||||
}
|
||||
|
||||
function proxifyWebVideoController (req: express.Request, res: express.Response) {
|
||||
const filename = req.params.filename
|
||||
|
||||
return proxifyWebVideoFile({ req, res, filename })
|
||||
}
|
||||
|
||||
function proxifyHLSController (req: express.Request, res: express.Response) {
|
||||
const playlist = res.locals.videoStreamingPlaylist
|
||||
const video = res.locals.onlyVideo
|
||||
const filename = req.params.filename
|
||||
|
||||
const reinjectVideoFileToken = filename.endsWith('.m3u8') && doReinjectVideoFileToken(req)
|
||||
|
||||
return proxifyHLS({
|
||||
req,
|
||||
res,
|
||||
playlist,
|
||||
video,
|
||||
filename,
|
||||
reinjectVideoFileToken
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue