change method of s3 check connect

This commit is contained in:
fyears 2024-01-02 23:52:36 +08:00
parent f55fad0e29
commit ee8a3df0be

View File

@ -509,6 +509,11 @@ export const deleteFromRemote = async (
/** /**
* Check the config of S3 by heading bucket * Check the config of S3 by heading bucket
* https://stackoverflow.com/questions/50842835 * 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 s3Client
* @param s3Config * @param s3Config
* @returns * @returns
@ -519,9 +524,15 @@ export const checkConnectivity = async (
callbackFunc?: any callbackFunc?: any
) => { ) => {
try { try {
const results = await s3Client.send( // const results = await s3Client.send(
new HeadBucketCommand({ Bucket: s3Config.s3BucketName }) // 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 ( if (
results === undefined || results === undefined ||
results.$metadata === undefined || results.$metadata === undefined ||