Skip to content

S3Client can't use virtual hosted style for customize endpoint. #2317

Description

@zmxnv1

Describe the bug

I want to use S3 V2 SDK to visit aliyun oss. The aliyun oss only supports virtual hosted.
But if I override the endpoint with "http://oss-cn-beijing.aliyuncs.com", the S3Client always chooses path style.

Expected Behavior

S3Client chooses virtual hosted style to request server.

Current Behavior

S3Client use path style.

Steps to Reproduce

S3Client client = S3Client.builder().endpointOverride(new URI("http://oss-cn-beijing.aliyuncs.com")).build();
client.putObject();   // the client will choose path style instead of virtual-hosted style.

Possible Solution

image

It will choose virtual-hosted style only the host startswith "s3"

Context

I can't use aws sdk to visit aliyun service.

Your Environment

  • AWS Java SDK version used: 2.15.67
  • JDK version used: 11 Coretto
  • Operating System and version: macOS Big Sur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.needs-discussionThis issue/PR requires more discussion with community.third-partyThis issue is related to third-party libraries or applications.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions