From 97981a150305347040f6f4896aad395183824cae Mon Sep 17 00:00:00 2001 From: warjiang <1096409085@qq.com> Date: Fri, 25 Oct 2024 04:14:06 +0800 Subject: [PATCH] feat: alignment with mc client (#1339) --- src/internal/client.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/internal/client.ts b/src/internal/client.ts index 8f18edac..0457c233 100644 --- a/src/internal/client.ts +++ b/src/internal/client.ts @@ -789,6 +789,14 @@ export class TypedClient { const res = await this.makeRequestAsync({ method, bucketName, query, pathStyle }, '', [200], DEFAULT_REGION) return extractRegionAsync(res) } catch (e) { + // make alignment with mc cli + if (e instanceof errors.S3Error) { + const errCode = e.code + const errRegion = e.region + if (errCode === 'AccessDenied' && !errRegion) { + return DEFAULT_REGION + } + } // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore if (!(e.name === 'AuthorizationHeaderMalformed')) {