From bd3b0f5b666354a1572a818a15cabd84873581b2 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Wed, 16 Dec 2020 11:23:26 +0100 Subject: [PATCH] openvidu-server: new OPENVIDU_PRO_AWS_S3_HEADERS property --- .../docker-compose/openvidu-server-pro/.env | 7 ++++++ .../server/config/OpenviduConfig.java | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/openvidu-server/deployments/pro/docker-compose/openvidu-server-pro/.env b/openvidu-server/deployments/pro/docker-compose/openvidu-server-pro/.env index 0805c8ce..4bec679d 100644 --- a/openvidu-server/deployments/pro/docker-compose/openvidu-server-pro/.env +++ b/openvidu-server/deployments/pro/docker-compose/openvidu-server-pro/.env @@ -168,6 +168,13 @@ OPENVIDU_PRO_CLUSTER_LOAD_STRATEGY=streams # if OPENVIDU_PRO_RECORDING_STORAGE=s3 #OPENVIDU_PRO_AWS_S3_BUCKET= +# If OPENVIDU_PRO_RECORDING_STORAGE=s3, the collection of HTTP header values that the internal AWS client will use during +# the upload process. The property is a key-value map of strings, following the format of a JSON object. For example, for applying +# server-side encryption with AES-256, this header is mandatory: {"x-amz-server-side-encryption":"AES256"}. +# The list of available headers can be found here: https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/Headers.html +# This property is only taken into account if OPENVIDU_PRO_RECORDING_STORAGE=s3 +#OPENVIDU_PRO_AWS_S3_HEADERS= + # If you're instance has a role which has access to read # and write into the s3 bucket, you don't need this parameter # OPENVIDU_PRO_AWS_ACCESS_KEY= diff --git a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java index 1e103b02..199350af 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java +++ b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import javax.annotation.PostConstruct; @@ -51,6 +52,8 @@ import org.springframework.stereotype.Component; import com.google.gson.Gson; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import io.openvidu.java.client.OpenViduRole; @@ -906,6 +909,25 @@ public class OpenviduConfig { } } + protected Map asOptionalStringMap(String property) { + Map map = new HashMap<>(); + String str = getValue(property); + if (str != null && !str.isEmpty()) { + try { + Gson gson = new Gson(); + JsonObject jsonObject = gson.fromJson(str, JsonObject.class); + for (Entry entry : jsonObject.entrySet()) { + map.put(entry.getKey(), entry.getValue().getAsString()); + } + return map; + } catch (JsonSyntaxException e) { + addError(property, "Is not a valid map of strings. " + e.getMessage()); + return map; + } + } + return map; + } + public URI checkWebsocketUri(String uri) throws Exception { try { if (!StringUtils.startsWithAny(uri, "ws://", "wss://")) {