Configure path-style in Java SDK Amazon S3

后端 未结 3 1393
一生所求
一生所求 2021-01-04 11:45

I\'m using AWS Java SDK provided by Amazon to interact with the S3 service.

It seems that by default, the SDK uses virtual-host-style for buckets (i.e. buckets are r

3条回答
  •  失恋的感觉
    2021-01-04 12:20

    For SDK v2 you can you enable path style by doing this:

        public S3Client build() {
    
            final S3Configuration config = S3Configuration.builder()
                    .pathStyleAccessEnabled(true)
                    .build();
    
            return S3Client.builder()
                    .serviceConfiguration(config)
                    // other set up
                    .build();
        }
    

    Amazon wass planning to deprecate path style access from Sept 2020, but this deprecation has been postponed: https://forums.aws.amazon.com/ann.jspa?annID=6776

提交回复
热议问题