Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .env.release.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ SKILLHUB_STORAGE_S3_ACCESS_KEY=replace-me
SKILLHUB_STORAGE_S3_SECRET_KEY=replace-me
SKILLHUB_STORAGE_S3_REGION=cn-shanghai
SKILLHUB_STORAGE_S3_FORCE_PATH_STYLE=false
# Aliyun OSS rejects aws-chunked encoding; set to true when targeting Aliyun OSS.
SKILLHUB_STORAGE_S3_DISABLE_CHUNKED_ENCODING=true
SKILLHUB_STORAGE_S3_AUTO_CREATE_BUCKET=false
SKILLHUB_STORAGE_S3_PRESIGN_EXPIRY=PT10M

Expand Down
1 change: 1 addition & 0 deletions server/skillhub-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ skillhub:
secret-key: ${SKILLHUB_STORAGE_S3_SECRET_KEY:}
region: ${SKILLHUB_STORAGE_S3_REGION:us-east-1}
force-path-style: ${SKILLHUB_STORAGE_S3_FORCE_PATH_STYLE:true}
disable-chunked-encoding: ${SKILLHUB_STORAGE_S3_DISABLE_CHUNKED_ENCODING:false}
auto-create-bucket: ${SKILLHUB_STORAGE_S3_AUTO_CREATE_BUCKET:false}
presign-expiry: ${SKILLHUB_STORAGE_S3_PRESIGN_EXPIRY:PT10M}
max-connections: ${SKILLHUB_STORAGE_S3_MAX_CONNECTIONS:100}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class S3StorageProperties {
private String secretKey;
private String region = "us-east-1";
private boolean forcePathStyle = true;
private boolean disableChunkedEncoding = false;
private boolean autoCreateBucket = false;
private Duration presignExpiry = Duration.ofMinutes(10);
private Integer maxConnections = 100;
Expand All @@ -36,6 +37,8 @@ public class S3StorageProperties {
public void setRegion(String region) { this.region = region; }
public boolean isForcePathStyle() { return forcePathStyle; }
public void setForcePathStyle(boolean forcePathStyle) { this.forcePathStyle = forcePathStyle; }
public boolean isDisableChunkedEncoding() { return disableChunkedEncoding; }
public void setDisableChunkedEncoding(boolean disableChunkedEncoding) { this.disableChunkedEncoding = disableChunkedEncoding; }
public boolean isAutoCreateBucket() { return autoCreateBucket; }
public void setAutoCreateBucket(boolean autoCreateBucket) { this.autoCreateBucket = autoCreateBucket; }
public Duration getPresignExpiry() { return presignExpiry; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ protected S3Client buildS3Client(ApacheHttpClient.Builder httpClientBuilder) {
var builder = S3Client.builder()
.region(Region.of(properties.getRegion()))
.credentialsProvider(buildCredentialsProvider())
.forcePathStyle(properties.isForcePathStyle())
.serviceConfiguration(S3Configuration.builder()
.pathStyleAccessEnabled(properties.isForcePathStyle())
.chunkedEncodingEnabled(!properties.isDisableChunkedEncoding())
.build())
.httpClientBuilder(httpClientBuilder)
.overrideConfiguration(config -> config
.apiCallAttemptTimeout(properties.getApiCallAttemptTimeout())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@

class S3StorageServiceTest {

@Test
void buildS3ClientShouldDisableChunkedEncodingWhenConfigured() {
S3StorageProperties props = createProperties(true);
props.setDisableChunkedEncoding(true);
S3StorageService service = new S3StorageService(props);
ApacheHttpClient.Builder httpClientBuilder = ApacheHttpClient.builder();
S3Client client = service.buildS3Client(httpClientBuilder);
assertThat(client).isNotNull();
client.close();
}

@Test
void shouldUsePathStylePresignedUrlWhenForcePathStyleEnabled() {
URI presignedUrl = presignGetObjectUrl(true);
Expand Down
Loading