Просмотр исходного кода

fix: replace empty `s3CustomEndpoint` with undefined

If empty string, cannot parse the string as URL and fail to upload file.
t_hikawa 10 месяцев назад
Родитель
Сommit
332db38b0b
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      apps/app/src/server/service/file-uploader/aws/index.ts

+ 3 - 2
apps/app/src/server/service/file-uploader/aws/index.ts

@@ -86,6 +86,7 @@ const getS3Bucket = (): string | undefined => {
 const S3Factory = (): S3Client => {
   const accessKeyId = configManager.getConfig('aws:s3AccessKeyId');
   const secretAccessKey = configManager.getConfig('aws:s3SecretAccessKey');
+  const s3CustomEndpoint = configManager.getConfig('aws:s3CustomEndpoint') || undefined
 
   return new S3Client({
     credentials: accessKeyId != null && secretAccessKey != null
@@ -95,8 +96,8 @@ const S3Factory = (): S3Client => {
       }
       : undefined,
     region: configManager.getConfig('aws:s3Region'),
-    endpoint: configManager.getConfig('aws:s3CustomEndpoint'),
-    forcePathStyle: configManager.getConfig('aws:s3CustomEndpoint') != null, // s3ForcePathStyle renamed to forcePathStyle in v3
+    endpoint: s3CustomEndpoint,
+    forcePathStyle: !!s3CustomEndpoint, // s3ForcePathStyle renamed to forcePathStyle in v3
   });
 };