]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/object-storage/videos.ts
Fix email action button label for reports
[github/Chocobozzz/PeerTube.git] / server / lib / object-storage / videos.ts
... / ...
CommitLineData
1import { join } from 'path'
2import { logger } from '@server/helpers/logger'
3import { CONFIG } from '@server/initializers/config'
4import { MStreamingPlaylistVideo, MVideoFile } from '@server/types/models'
5import { getHLSDirectory } from '../paths'
6import { generateHLSObjectBaseStorageKey, generateHLSObjectStorageKey, generateWebTorrentObjectStorageKey } from './keys'
7import { lTags, makeAvailable, removeObject, removePrefix, storeObject } from './shared'
8
9function storeHLSFile (playlist: MStreamingPlaylistVideo, filename: string, path?: string) {
10 return storeObject({
11 inputPath: path ?? join(getHLSDirectory(playlist.Video), filename),
12 objectStorageKey: generateHLSObjectStorageKey(playlist, filename),
13 bucketInfo: CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS
14 })
15}
16
17function storeWebTorrentFile (filename: string) {
18 return storeObject({
19 inputPath: join(CONFIG.STORAGE.VIDEOS_DIR, filename),
20 objectStorageKey: generateWebTorrentObjectStorageKey(filename),
21 bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS
22 })
23}
24
25function removeHLSObjectStorage (playlist: MStreamingPlaylistVideo) {
26 return removePrefix(generateHLSObjectBaseStorageKey(playlist), CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS)
27}
28
29function removeWebTorrentObjectStorage (videoFile: MVideoFile) {
30 return removeObject(generateWebTorrentObjectStorageKey(videoFile.filename), CONFIG.OBJECT_STORAGE.VIDEOS)
31}
32
33async function makeHLSFileAvailable (playlist: MStreamingPlaylistVideo, filename: string, destination: string) {
34 const key = generateHLSObjectStorageKey(playlist, filename)
35
36 logger.info('Fetching HLS file %s from object storage to %s.', key, destination, lTags())
37
38 await makeAvailable({
39 key,
40 destination,
41 bucketInfo: CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS
42 })
43
44 return destination
45}
46
47async function makeWebTorrentFileAvailable (filename: string, destination: string) {
48 const key = generateWebTorrentObjectStorageKey(filename)
49
50 logger.info('Fetching WebTorrent file %s from object storage to %s.', key, destination, lTags())
51
52 await makeAvailable({
53 key,
54 destination,
55 bucketInfo: CONFIG.OBJECT_STORAGE.VIDEOS
56 })
57
58 return destination
59}
60
61export {
62 storeWebTorrentFile,
63 storeHLSFile,
64
65 removeHLSObjectStorage,
66 removeWebTorrentObjectStorage,
67
68 makeWebTorrentFileAvailable,
69 makeHLSFileAvailable
70}