cynx-lib 1.3.39 → 1.3.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -367,15 +367,26 @@ export class StorageManager {
|
|
|
367
367
|
if (!region || !accessKeyId || !secretAccessKey) {
|
|
368
368
|
throw new Error('Неполные данные подключения Amazon S3 (Region, Access Key ID, Secret Access Key)');
|
|
369
369
|
}
|
|
370
|
+
const reg = (region && region.trim() && region.trim().toLowerCase() !== 'auto') ? region.trim() : 'us-east-1';
|
|
370
371
|
const clientOpts = {
|
|
371
|
-
region:
|
|
372
|
+
region: reg,
|
|
372
373
|
credentials: {
|
|
373
374
|
accessKeyId: accessKeyId.trim(),
|
|
374
375
|
secretAccessKey: secretAccessKey.trim(),
|
|
375
376
|
},
|
|
376
377
|
};
|
|
377
378
|
if (endpoint && endpoint.trim()) {
|
|
378
|
-
|
|
379
|
+
let cleanEndpoint = endpoint.trim();
|
|
380
|
+
if (!/^https?:\/\//i.test(cleanEndpoint)) {
|
|
381
|
+
cleanEndpoint = `https://${cleanEndpoint}`;
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
const parsed = new URL(cleanEndpoint);
|
|
385
|
+
cleanEndpoint = parsed.origin;
|
|
386
|
+
} catch {
|
|
387
|
+
cleanEndpoint = cleanEndpoint.replace(/\/+$/, '');
|
|
388
|
+
}
|
|
389
|
+
clientOpts.endpoint = cleanEndpoint;
|
|
379
390
|
clientOpts.forcePathStyle = true;
|
|
380
391
|
}
|
|
381
392
|
return new S3Client(clientOpts);
|
|
@@ -647,6 +658,10 @@ export class StorageManager {
|
|
|
647
658
|
let base = publicDomain.trim().replace(/\/+$/, '');
|
|
648
659
|
if (!/^https?:\/\//i.test(base)) base = `https://${base}`;
|
|
649
660
|
cloudUrl = `${base}/${objectKey}`;
|
|
661
|
+
} else if (endpoint && endpoint.trim()) {
|
|
662
|
+
let base = endpoint.trim().replace(/\/+$/, '');
|
|
663
|
+
if (!/^https?:\/\//i.test(base)) base = `https://${base}`;
|
|
664
|
+
cloudUrl = `${base}/${bucket.trim()}/${objectKey}`;
|
|
650
665
|
} else if (provider === 's3') {
|
|
651
666
|
const reg = region ? region.trim() : 'us-east-1';
|
|
652
667
|
cloudUrl = `https://${bucket.trim()}.s3.${reg}.amazonaws.com/${objectKey}`;
|