From bef0c6f53315e405bc39e72b63eab74dc7fb1d3b Mon Sep 17 00:00:00 2001 From: David Zhou Date: Wed, 28 May 2025 19:00:43 +0800 Subject: [PATCH] add tencent COS endpoint check --- storage/s3.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/storage/s3.go b/storage/s3.go index 3313be66e..cfb79710a 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -48,6 +48,9 @@ const ( // Google Cloud Storage endpoint gcsEndpoint = "storage.googleapis.com" + // Tencent Cloud COS endpoint + cosEndpoint = ".myqcloud.com" + // the key of the object metadata which is used to handle retry decision on NoSuchUpload error metadataKeyRetryID = "s5cmd-upload-retry-id" ) @@ -1422,11 +1425,15 @@ func IsGoogleEndpoint(endpoint urlpkg.URL) bool { return endpoint.Hostname() == gcsEndpoint } +func IsTencentEndpoint(endpoint urlpkg.URL) bool { + return strings.HasSuffix(endpoint.Hostname(), cosEndpoint) +} + // isVirtualHostStyle reports whether the given endpoint supports S3 virtual // host style bucket name resolving. If a custom S3 API compatible endpoint is // given, resolve the bucketname from the URL path. func isVirtualHostStyle(endpoint urlpkg.URL) bool { - return endpoint == sentinelURL || supportsTransferAcceleration(endpoint) || IsGoogleEndpoint(endpoint) + return endpoint == sentinelURL || supportsTransferAcceleration(endpoint) || IsGoogleEndpoint(endpoint) || IsTencentEndpoint(endpoint) } func errHasCode(err error, code string) bool {