Skip to content

Commit

Permalink
Merge pull request #6671 from ant-media/s3PathStyleAccessConfiguration
Browse files Browse the repository at this point in the history
Add s3PathStyleAccessEnabled setting
  • Loading branch information
mekya authored Jan 29, 2025
2 parents 5dee0fa + d139310 commit bfd767e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/antmedia/AntMediaApplicationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,7 @@ public void setStorageclientSettings(AppSettings settings) {
storageClient.setPermission(settings.getS3Permission());
storageClient.setStorageClass(settings.getS3StorageClass());
storageClient.setCacheControl(settings.getS3CacheControl());
storageClient.setPathStyleAccessEnabled(settings.isS3PathStyleAccessEnabled());
storageClient.setTransferBufferSize(settings.getS3TransferBufferSizeInBytes());
storageClient.reset();
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/io/antmedia/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ public class AppSettings implements Serializable{
* @hidden
*/
private static final String SETTINGS_S3_CACHE_CONTROL = "settings.s3CacheControl";

/**
* @hidden
*/
Expand Down Expand Up @@ -2057,6 +2058,13 @@ public class AppSettings implements Serializable{
@Value("${s3CacheControl:${"+SETTINGS_S3_CACHE_CONTROL+":no-store, no-cache, must-revalidate, max-age=0}}")
private String s3CacheControl = "no-store, no-cache, must-revalidate, max-age=0";


/**
* S3 Path Syle Access Enabled
*/
@Value("${s3PathStyleAccessEnabled:false}")
private boolean s3PathStyleAccessEnabled = false;

/*
* The permission to use in uploading the files to the S3.
* Following values are accepted. Default value is public-read
Expand Down Expand Up @@ -3687,6 +3695,14 @@ public void setS3CacheControl(String s3CacheControl) {
this.s3CacheControl = s3CacheControl;
}

public boolean isS3PathStyleAccessEnabled() {
return s3PathStyleAccessEnabled;
}

public void setS3PathStyleAccessEnabled(boolean s3PathStyleAccessEnabled) {
this.s3PathStyleAccessEnabled = s3PathStyleAccessEnabled;
}

public void setDashHttpEndpoint(String dashHttpEndpoint) {
this.dashHttpEndpoint = dashHttpEndpoint;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/antmedia/storage/AmazonS3StorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public AmazonS3 initAmazonS3() {
builder.withClientConfiguration(
new ClientConfiguration().withMaxConnections(100)
.withConnectionTimeout(120 * 1000)
.withMaxErrorRetry(15));
.withMaxErrorRetry(15))
.withPathStyleAccessEnabled(isPathStyleAccessEnabled())
;

return builder.build();
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/antmedia/storage/StorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public abstract class StorageClient {

protected ProgressListener progressListener;

private boolean pathStyleAccessEnabled;

private int transferBufferSize;

/**
Expand Down Expand Up @@ -182,6 +184,14 @@ public void setCacheControl(String cacheControl) {
this.cacheControl = cacheControl;
}

public void setPathStyleAccessEnabled(boolean enabled) {
this.pathStyleAccessEnabled = enabled;
}

public boolean isPathStyleAccessEnabled() {
return pathStyleAccessEnabled;
}

public int getTransferBufferSize() {
return transferBufferSize;
}
Expand Down
10 changes: 7 additions & 3 deletions src/test/java/io/antmedia/test/AppSettingsUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,19 @@ public void testUnsetAppSettings(AppSettings appSettings) {

assertNull(appSettings.getRecordingSubfolder());
assertEquals("application/json", appSettings.getWebhookContentType());

assertFalse(appSettings.isS3PathStyleAccessEnabled());

appSettings.setS3PathStyleAccessEnabled(true);

assertTrue(appSettings.isS3PathStyleAccessEnabled());

assertEquals(2000, appSettings.getIceGatheringTimeoutMs());

assertNotNull(appSettings.getParticipantVisibilityMatrix());


Map<String, List<String>> trackSelectionMode = appSettings.getParticipantVisibilityMatrix();


assertEquals(4, trackSelectionMode.size());
assertEquals(1, trackSelectionMode.get("default").size());
assertEquals(Arrays.asList("default"), trackSelectionMode.get("default"));
Expand Down Expand Up @@ -685,7 +689,7 @@ public void testUnsetAppSettings(AppSettings appSettings) {
//by also checking its default value.

assertEquals("New field is added to settings. PAY ATTENTION: Please CHECK ITS DEFAULT VALUE and fix the number of fields.",
199, numberOfFields);
200, numberOfFields);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void testS3() {
storage.setRegion("eu-west-1");
storage.setStorageName(BUCKET_NAME);
storage.setStorageClass("STANDARD");
storage.setPathStyleAccessEnabled(false);

File f = new File("src/test/resources/test.flv");
storage.setEnabled(true);
Expand Down

0 comments on commit bfd767e

Please sign in to comment.