1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Fix CI tests

This commit is contained in:
Chocobozzz 2023-06-06 11:14:13 +02:00
parent 881958d179
commit c37e305342
No known key found for this signature in database
GPG key ID: 583A612D890159BE
41 changed files with 133 additions and 72 deletions

View file

@ -0,0 +1,41 @@
import { GetObjectCommand } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
import { CONFIG } from '@server/initializers/config'
import { MStreamingPlaylistVideo, MVideoFile } from '@server/types/models'
import { generateHLSObjectStorageKey, generateWebTorrentObjectStorageKey } from './keys'
import { buildKey, getClient } from './shared'
export function generateWebVideoPresignedUrl (options: {
file: MVideoFile
downloadFilename: string
}) {
const { file, downloadFilename } = options
const key = generateWebTorrentObjectStorageKey(file.filename)
const command = new GetObjectCommand({
Bucket: CONFIG.OBJECT_STORAGE.VIDEOS.BUCKET_NAME,
Key: buildKey(key, CONFIG.OBJECT_STORAGE.VIDEOS),
ResponseContentDisposition: `attachment; filename=${downloadFilename}`
})
return getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 })
}
export function generateHLSFilePresignedUrl (options: {
streamingPlaylist: MStreamingPlaylistVideo
file: MVideoFile
downloadFilename: string
}) {
const { streamingPlaylist, file, downloadFilename } = options
const key = generateHLSObjectStorageKey(streamingPlaylist, file.filename)
const command = new GetObjectCommand({
Bucket: CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET_NAME,
Key: buildKey(key, CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS),
ResponseContentDisposition: `attachment; filename=${downloadFilename}`
})
return getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 })
}