From ff75ba7160abd28460425b0f13371f5d41501e77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jun 2023 11:59:00 +0200 Subject: [PATCH] Also replace base url of pre signed s3 url --- server/lib/object-storage/pre-signed-urls.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/lib/object-storage/pre-signed-urls.ts b/server/lib/object-storage/pre-signed-urls.ts index 46a0750a1..d8473d01e 100644 --- a/server/lib/object-storage/pre-signed-urls.ts +++ b/server/lib/object-storage/pre-signed-urls.ts @@ -4,8 +4,9 @@ import { CONFIG } from '@server/initializers/config' import { MStreamingPlaylistVideo, MVideoFile } from '@server/types/models' import { generateHLSObjectStorageKey, generateWebTorrentObjectStorageKey } from './keys' import { buildKey, getClient } from './shared' +import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from './urls' -export function generateWebVideoPresignedUrl (options: { +export async function generateWebVideoPresignedUrl (options: { file: MVideoFile downloadFilename: string }) { @@ -19,10 +20,12 @@ export function generateWebVideoPresignedUrl (options: { ResponseContentDisposition: `attachment; filename=${downloadFilename}` }) - return getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 }) + const url = await getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 }) + + return getWebTorrentPublicFileUrl(url) } -export function generateHLSFilePresignedUrl (options: { +export async function generateHLSFilePresignedUrl (options: { streamingPlaylist: MStreamingPlaylistVideo file: MVideoFile downloadFilename: string @@ -37,5 +40,7 @@ export function generateHLSFilePresignedUrl (options: { ResponseContentDisposition: `attachment; filename=${downloadFilename}` }) - return getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 }) + const url = await getSignedUrl(getClient(), command, { expiresIn: 3600 * 24 }) + + return getHLSPublicFileUrl(url) }