Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add s3PathStyleAccessEnabled setting #6671

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1990,6 +1990,7 @@ public void setStorageclientSettings(AppSettings settings) {
storageClient.setPermission(settings.getS3Permission());
storageClient.setStorageClass(settings.getS3StorageClass());
storageClient.setCacheControl(settings.getS3CacheControl());
storageClient.setPathStyleAccessEnabled(settings.isS3PathStyleAccessEnabled());
storageClient.reset();
}

Expand Down
21 changes: 21 additions & 0 deletions src/main/java/io/antmedia/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ public class AppSettings implements Serializable{
* @hidden
*/
private static final String SETTINGS_S3_CACHE_CONTROL = "settings.s3CacheControl";

/**
* @hidden
*/
private static final String SETTINGS_S3_PATH_STYLE_ACCESS_ENABLED = "settings.pathStyleAccessEnabled";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this convention anymore. We directly use field name. Please remove it.


/**
* @hidden
*/
Expand Down Expand Up @@ -1859,6 +1865,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:${"+SETTINGS_S3_PATH_STYLE_ACCESS_ENABLED+":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 @@ -3420,6 +3433,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 @@ -70,7 +70,9 @@ public AmazonS3 initAmazonS3() {
builder.withClientConfiguration(
new ClientConfiguration().withMaxConnections(100)
.withConnectionTimeout(120 * 1000)
.withMaxErrorRetry(15));
.withMaxErrorRetry(15))
.withPathStyleAccessEnabled(isPathStyleAccessEnabled())
;

return builder.build();
}
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/io/antmedia/storage/StorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public abstract class StorageClient {

protected ProgressListener progressListener;


private boolean pathStyleAccessEnabled;


/**
* Delete file from storage
*
Expand Down Expand Up @@ -180,4 +182,12 @@ public String getCacheControl() {
public void setCacheControl(String cacheControl) {
this.cacheControl = cacheControl;
}

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

public boolean isPathStyleAccessEnabled() {
return pathStyleAccessEnabled;
}
}
11 changes: 8 additions & 3 deletions src/test/java/io/antmedia/test/AppSettingsUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -598,16 +598,21 @@ public void testUnsetAppSettings(AppSettings appSettings) {
assertTrue(appSettings.isRelayRTMPMetaDataToMuxers());

assertFalse(appSettings.isDropWebRTCIngestIfNoPacketReceived());



assertFalse(appSettings.isS3PathStyleAccessEnabled());

appSettings.setS3PathStyleAccessEnabled(true);

assertTrue(appSettings.isS3PathStyleAccessEnabled());



//if we add a new field, we just need to check its default value in this test
//When a new field is added or removed please update the number of fields and make this test pass
//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.",
186, numberOfFields);
187, numberOfFields);


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,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
Loading