From ee8a3df0be270a9cc8136656dbd344fe63a6f079 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:52:36 +0800 Subject: [PATCH] change method of s3 check connect --- src/remoteForS3.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/remoteForS3.ts b/src/remoteForS3.ts index e028888..ddee612 100644 --- a/src/remoteForS3.ts +++ b/src/remoteForS3.ts @@ -509,6 +509,11 @@ export const deleteFromRemote = async ( /** * Check the config of S3 by heading bucket * https://stackoverflow.com/questions/50842835 + * + * Updated on 20240102: + * Users are not always have permission of heading bucket, + * so we need to use listing objects instead... + * * @param s3Client * @param s3Config * @returns @@ -519,9 +524,15 @@ export const checkConnectivity = async ( callbackFunc?: any ) => { try { - const results = await s3Client.send( - new HeadBucketCommand({ Bucket: s3Config.s3BucketName }) - ); + // const results = await s3Client.send( + // new HeadBucketCommand({ Bucket: s3Config.s3BucketName }) + // ); + // very simplified version of listing objects + const confCmd = { + Bucket: s3Config.s3BucketName, + } as ListObjectsV2CommandInput; + const results = await s3Client.send(new ListObjectsV2Command(confCmd)); + if ( results === undefined || results.$metadata === undefined ||