From 80db40b0f025d09085d1e08f20e96faee8e1bf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E8=90=8C=E5=93=92=E8=B5=AB=E8=90=9D?= Date: Tue, 29 Aug 2023 00:12:53 -0700 Subject: [PATCH] :bug: Fix: fix an issue where files uploaded to minio using s3 plugin can't be deleted remotely --- src/main/utils/deleteFunc.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/utils/deleteFunc.ts b/src/main/utils/deleteFunc.ts index 34e2e55d..53f4ef23 100644 --- a/src/main/utils/deleteFunc.ts +++ b/src/main/utils/deleteFunc.ts @@ -75,7 +75,10 @@ export async function removeFileFromS3InMain (configMap: IStringKeyMap, dogeMode try { const { imgUrl, config: { accessKeyID, secretAccessKey, bucketName, region, endpoint, pathStyleAccess, rejectUnauthorized, proxy } } = configMap const url = new URL(!/^https?:\/\//.test(imgUrl) ? `http://${imgUrl}` : imgUrl) - const fileKey = url.pathname.replace(/^\/+/, '') + let fileKey = url.pathname.replace(/^\/+/, '') + if (pathStyleAccess) { + fileKey = fileKey.replace(/^[^/]+\//, '') + } const endpointUrl: string | undefined = endpoint ? /^https?:\/\//.test(endpoint) ? endpoint