Package com.example.blogs.app.config
Class S3Config
java.lang.Object
com.example.blogs.app.config.S3Config
Configuration class for AWS S3 client with support for custom endpoints and path-style access.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsoftware.amazon.awssdk.services.s3.S3ClientlocalS3Client(String region, String accessKey, String secretKey, String endpoint) Creates an S3 client configured for local development with custom endpoint.software.amazon.awssdk.services.s3.S3ClientprodS3Client(String region) Creates an S3 client configured for production with default AWS credentials.
-
Constructor Details
-
S3Config
public S3Config()
-
-
Method Details
-
localS3Client
@Bean @Profile("local") public software.amazon.awssdk.services.s3.S3Client localS3Client(@Value("${aws.region}") String region, @Value("${aws.accessKey}") String accessKey, @Value("${aws.secretKey}") String secretKey, @Value("${aws.endpoint}") String endpoint) Creates an S3 client configured for local development with custom endpoint. Active only in the local profile for integration with LocalStack or similar services.- Parameters:
region- the AWS regionaccessKey- the AWS access keysecretKey- the AWS secret keyendpoint- the custom S3 endpoint URL- Returns:
- configured S3Client instance with path-style access enabled
-
prodS3Client
@Bean @Profile("prod") public software.amazon.awssdk.services.s3.S3Client prodS3Client(@Value("${aws.region}") String region) Creates an S3 client configured for production with default AWS credentials. Active only in the production profile and uses IAM roles or default credential chain.- Parameters:
region- the AWS region- Returns:
- configured S3Client instance with default credentials
-