From 9ab330b90decf4edf152ff8e1d2948c065766b2c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Oct 2022 10:43:53 +0200 Subject: Use private ACL for private videos in s3 --- server/lib/object-storage/urls.ts | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'server/lib/object-storage/urls.ts') diff --git a/server/lib/object-storage/urls.ts b/server/lib/object-storage/urls.ts index 2a889190b..a47a98b98 100644 --- a/server/lib/object-storage/urls.ts +++ b/server/lib/object-storage/urls.ts @@ -1,10 +1,14 @@ import { CONFIG } from '@server/initializers/config' +import { OBJECT_STORAGE_PROXY_PATHS, WEBSERVER } from '@server/initializers/constants' +import { MVideoUUID } from '@server/types/models' import { BucketInfo, buildKey, getEndpointParsed } from './shared' -function getPrivateUrl (config: BucketInfo, keyWithoutPrefix: string) { +function getInternalUrl (config: BucketInfo, keyWithoutPrefix: string) { return getBaseUrl(config) + buildKey(keyWithoutPrefix, config) } +// --------------------------------------------------------------------------- + function getWebTorrentPublicFileUrl (fileUrl: string) { const baseUrl = CONFIG.OBJECT_STORAGE.VIDEOS.BASE_URL if (!baseUrl) return fileUrl @@ -19,11 +23,28 @@ function getHLSPublicFileUrl (fileUrl: string) { return replaceByBaseUrl(fileUrl, baseUrl) } +// --------------------------------------------------------------------------- + +function getHLSPrivateFileUrl (video: MVideoUUID, filename: string) { + return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.STREAMING_PLAYLISTS.PRIVATE_HLS + video.uuid + `/${filename}` +} + +function getWebTorrentPrivateFileUrl (filename: string) { + return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + filename +} + +// --------------------------------------------------------------------------- + export { - getPrivateUrl, + getInternalUrl, + getWebTorrentPublicFileUrl, - replaceByBaseUrl, - getHLSPublicFileUrl + getHLSPublicFileUrl, + + getHLSPrivateFileUrl, + getWebTorrentPrivateFileUrl, + + replaceByBaseUrl } // --------------------------------------------------------------------------- -- cgit v1.2.3