@@ -50,6 +50,8 @@ const (
5050
5151 // the key of the object metadata which is used to handle retry decision on NoSuchUpload error
5252 metadataKeyRetryID = "s5cmd-upload-retry-id"
53+
54+ AddressingVirtualHostStyle = "virtual"
5355)
5456
5557// Re-used AWS sessions dramatically improve performance.
@@ -1255,7 +1257,7 @@ func (sc *SessionCache) newSession(ctx context.Context, opts Options) (*session.
12551257
12561258 // use virtual-host-style if the endpoint is known to support it,
12571259 // otherwise use the path-style approach.
1258- isVirtualHostStyle := isVirtualHostStyle (endpointURL )
1260+ isVirtualHostStyle := isVirtualHostStyle (endpointURL , opts . AddressingStyle )
12591261
12601262 useAccelerate := supportsTransferAcceleration (endpointURL )
12611263 // AWS SDK handles transfer acceleration automatically. Setting the
@@ -1422,11 +1424,18 @@ func IsGoogleEndpoint(endpoint urlpkg.URL) bool {
14221424 return endpoint .Hostname () == gcsEndpoint
14231425}
14241426
1427+ func ForcedVirtualHostStyle (endpoint urlpkg.URL , addressingStyle string ) bool {
1428+ return addressingStyle == AddressingVirtualHostStyle
1429+ }
1430+
14251431// isVirtualHostStyle reports whether the given endpoint supports S3 virtual
14261432// host style bucket name resolving. If a custom S3 API compatible endpoint is
14271433// given, resolve the bucketname from the URL path.
1428- func isVirtualHostStyle (endpoint urlpkg.URL ) bool {
1429- return endpoint == sentinelURL || supportsTransferAcceleration (endpoint ) || IsGoogleEndpoint (endpoint )
1434+ func isVirtualHostStyle (endpoint urlpkg.URL , addressingStyle string ) bool {
1435+ return endpoint == sentinelURL ||
1436+ supportsTransferAcceleration (endpoint ) ||
1437+ IsGoogleEndpoint (endpoint ) ||
1438+ ForcedVirtualHostStyle (endpoint , addressingStyle )
14301439}
14311440
14321441func errHasCode (err error , code string ) bool {
0 commit comments