diff --git a/bucket-cache.go b/bucket-cache.go index cafb4568b..8258212be 100644 --- a/bucket-cache.go +++ b/bucket-cache.go @@ -194,8 +194,8 @@ func (c *Client) getBucketLocationRequest(ctx context.Context, bucketName string var urlStr string - // only support Aliyun OSS for virtual hosted path, compatible Amazon & Google Endpoint - if isVirtualHost && s3utils.IsAliyunOSSEndpoint(targetURL) { + // only support Aliyun OSS & Ksyun KS3 for virtual hosted path, compatible Amazon & Google Endpoint + if isVirtualHost && (s3utils.IsAliyunOSSEndpoint(targetURL) || s3utils.IsKsyunKS3Endpoint(targetURL)) { urlStr = c.endpointURL.Scheme + "://" + bucketName + "." + targetURL.Host + "/?location" } else { targetURL.Path = path.Join(bucketName, "") + "/" diff --git a/pkg/s3utils/utils.go b/pkg/s3utils/utils.go index 79c129466..b262b2dba 100644 --- a/pkg/s3utils/utils.go +++ b/pkg/s3utils/utils.go @@ -78,7 +78,7 @@ func IsVirtualHostSupported(endpointURL url.URL, bucketName string) bool { return false } // Return true for all other cases - return IsAmazonEndpoint(endpointURL) || IsGoogleEndpoint(endpointURL) || IsAliyunOSSEndpoint(endpointURL) + return IsAmazonEndpoint(endpointURL) || IsGoogleEndpoint(endpointURL) || IsAliyunOSSEndpoint(endpointURL) || IsKsyunKS3Endpoint(endpointURL) } // Refer for region styles - https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region @@ -172,6 +172,11 @@ func IsAliyunOSSEndpoint(endpointURL url.URL) bool { return strings.HasSuffix(endpointURL.Host, "aliyuncs.com") } +// IsKsyunKS3Endpoint - Match if it is exactly Ksyun KS3 endpoint. +func IsKsyunKS3Endpoint(endpointURL url.URL) bool { + return strings.HasSuffix(endpointURL.Host, "ksyuncs.com") || strings.HasSuffix(endpointURL.Host, "ksyun.com") +} + // IsAmazonEndpoint - Match if it is exactly Amazon S3 endpoint. func IsAmazonEndpoint(endpointURL url.URL) bool { if endpointURL.Host == "s3-external-1.amazonaws.com" || endpointURL.Host == "s3.amazonaws.com" {