Handle S3 disabled better.

This commit is contained in:
Kavin 2023-02-02 15:52:51 +00:00
parent b7d4187ff3
commit 705a52cb7d
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
2 changed files with 11 additions and 0 deletions

View File

@ -174,6 +174,7 @@ public class Constants {
YOUTUBE_SERVICE.getSupportedCountries().stream().map(ContentCountry::getCountryCode)
.map(JsonNodeFactory.instance::textNode).toList()
);
frontendProperties.put("s3Enabled", S3_CLIENT != null);
// transform hibernate properties for legacy configurations
hibernateProperties.replace("hibernate.dialect",

View File

@ -21,6 +21,9 @@ public class StorageHandlers {
public static byte[] statFile(String session, String name) throws Exception {
if (Constants.S3_CLIENT == null)
ExceptionHandler.throwErrorResponse(new SimpleErrorMessage("Storage is not configured on this instance!"));
if (!StringUtils.isAlphanumeric(name) || name.length() > 32)
ExceptionHandler.throwErrorResponse(new SimpleErrorMessage("Invalid path provided!"));
@ -56,6 +59,9 @@ public class StorageHandlers {
public static byte[] putFile(String session, String name, String etag, byte[] content) throws Exception {
if (Constants.S3_CLIENT == null)
ExceptionHandler.throwErrorResponse(new SimpleErrorMessage("Storage is not configured on this instance!"));
if (!StringUtils.isAlphanumeric(name) || name.length() > 32)
ExceptionHandler.throwErrorResponse(new SimpleErrorMessage("Invalid path provided!"));
@ -102,6 +108,10 @@ public class StorageHandlers {
}
public static byte[] getFile(String session, String name) throws Exception {
if (Constants.S3_CLIENT == null)
ExceptionHandler.throwErrorResponse(new SimpleErrorMessage("Storage is not configured on this instance!"));
if (!StringUtils.isAlphanumeric(name) || name.length() > 32)
ExceptionHandler.throwErrorResponse(new SimpleErrorMessage("Invalid path provided!"));