fix(helpers): Normalize and robustly parse S3 endpoint configuration; use normalized descriptor in SmartBucket and update dev tooling
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import * as plugins from './plugins.js';
|
||||
import { Bucket } from './classes.bucket.js';
|
||||
import { normalizeS3Descriptor } from './helpers.js';
|
||||
|
||||
export class SmartBucket {
|
||||
public config: plugins.tsclass.storage.IS3Descriptor;
|
||||
@@ -17,18 +18,14 @@ export class SmartBucket {
|
||||
constructor(configArg: plugins.tsclass.storage.IS3Descriptor) {
|
||||
this.config = configArg;
|
||||
|
||||
const protocol = configArg.useSsl === false ? 'http' : 'https';
|
||||
const port = configArg.port ? `:${configArg.port}` : '';
|
||||
const endpoint = `${protocol}://${configArg.endpoint}${port}`;
|
||||
// Use the normalizer to handle various endpoint formats
|
||||
const { normalized } = normalizeS3Descriptor(configArg);
|
||||
|
||||
this.s3Client = new plugins.s3.S3Client({
|
||||
endpoint,
|
||||
region: configArg.region || 'us-east-1',
|
||||
credentials: {
|
||||
accessKeyId: configArg.accessKey,
|
||||
secretAccessKey: configArg.accessSecret,
|
||||
},
|
||||
forcePathStyle: true, // Necessary for S3-compatible storage like MinIO or Wasabi
|
||||
endpoint: normalized.endpointUrl,
|
||||
region: normalized.region,
|
||||
credentials: normalized.credentials,
|
||||
forcePathStyle: normalized.forcePathStyle, // Necessary for S3-compatible storage like MinIO or Wasabi
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user