diff --git a/config/default.yaml b/config/default.yaml index d09e465a661f..aef2c014a470 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -102,18 +102,11 @@ s3: streaming_playlists_bucket: '' # Allows setting all buckets to the same value but with a different prefix streaming_playlists_prefix: '' - # Optional, use to overide the default url generation that just gives the public url to s3 - # Use the string %path% in place where the (full) path to the file should be. The path - # does not include the streaming_playlists_prefix, so you should add it to your template if needed. - # For example: - # https://my-videos-cache.example.com/cdn-cache/%path%?thing=true - # Would turn into: - # https://my-videos-cache.example.com/cdn-cache/hls/9ffceb57-cbe3-41c5-80e4-dbb7e97c3958/b27d1892-9c5c-4bef-8bce-f68e54fb1208-240-fragmented.mp4?thing=true - streaming_playlists_url_template: '' + streaming_playlists_base_url: '' # Same settings but for webtorrent videos videos_bucket: '' videos_prefix: '' - videos_url_template: '' + videos_url_base_url: '' log: level: 'info' # 'debug' | 'info' | 'warn' | 'error' diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 384884ef7563..2adb8a56217b 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts @@ -169,13 +169,6 @@ function checkConfig () { return 'Object storage bucket prefixes should be set to different values when the same bucket is used for both types of video.' } } - if ( - (CONFIG.S3.VIDEOS_BUCKETINFO.url_template !== '' && - !CONFIG.S3.VIDEOS_BUCKETINFO.url_template.includes('%path%')) || - (CONFIG.S3.STREAMING_PLAYLISTS_BUCKETINFO.url_template !== '' && - !CONFIG.S3.STREAMING_PLAYLISTS_BUCKETINFO.url_template.includes('%path%'))) { - return 'Object storage url templates should include `%path%\' in place where the file path needs to be inserted.' - } } return null diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 36fdf07ead65..82f942296b6d 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -79,12 +79,12 @@ const CONFIG = { VIDEOS_BUCKETINFO: { bucket: config.get('s3.videos_bucket'), prefix: config.get('s3.videos_prefix'), - url_template: config.get('s3.videos_url_template') + base_url: config.get('s3.videos_base_url') }, STREAMING_PLAYLISTS_BUCKETINFO: { bucket: config.get('s3.streaming_playlists_bucket'), prefix: config.get('s3.streaming_playlists_prefix'), - url_template: config.get('s3.streaming_playlists_url_template') + base_url: config.get('s3.streaming_playlists_base_url') } }, WEBSERVER: { diff --git a/server/lib/object-storage.ts b/server/lib/object-storage.ts index 25223044bec1..458532cb1d10 100644 --- a/server/lib/object-storage.ts +++ b/server/lib/object-storage.ts @@ -3,7 +3,7 @@ import { DeleteObjectCommand, DeleteObjectsCommand, ListObjectsV2Command, PutObj import { CONFIG } from "@server/initializers/config" import { logger } from '@server/helpers/logger' -type BucketInfo = {bucket: string, prefix?: string, url_template?: string} +type BucketInfo = {bucket: string, prefix?: string, base_url?: string} function getS3Client () { return new S3Client({ endpoint: `https://${CONFIG.S3.ENDPOINT}` }) @@ -65,8 +65,8 @@ export async function removePrefix (prefix: string, bucketInfo: BucketInfo) { } export function generateUrl (filename: string, bucketInfo: BucketInfo) { - if (!bucketInfo.url_template) { + if (!bucketInfo.base_url) { return `https://${bucketInfo.bucket}.${CONFIG.S3.ENDPOINT}/${bucketInfo.prefix}${filename}` } - return bucketInfo.url_template.replace('%path%', filename) + return bucketInfo.base_url + filename }