Implement S3 force path-style support

This commit is contained in:
ohmwraith authored and Rory& committed 2026-04-29 19:35:38 +02:00
1 parent d9d339882b
commit 50c7da9872
2 files changed
+10 -2

No files matched your search

+2 -1
View File
@@ -33,10 +33,11 @@ export class S3Storage implements Storage {
private region: string,
private bucket: string,
private endpoint: string,
private forcePathStyle: boolean,
private basePath?: string,
) {
const { S3 } = require("@aws-sdk/client-s3");
this.client = new S3({ region: region, endpoint: endpoint });
this.client = new S3({ region: region, endpoint: endpoint, forcePathStyle: forcePathStyle });
}
isFile(path: string): Promise<boolean> {
return this.exists(path);
+8 -1
View File
@@ -82,8 +82,15 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) {
location = undefined;
}
// if false, the bucket name is used as a subdomain
const forcePathStyle = process.env.STORAGE_FORCE_PATH_STYLE === "true";
if (process.env.STORAGE_FORCE_PATH_STYLE === undefined) {
console.warn(`[CDN] STORAGE_FORCE_PATH_STYLE unconfigured for S3 provider, defaulting to use virtual-hosted style...`);
}
const { S3Storage } = require("./S3Storage");
storage = new S3Storage(region, bucket, endpoint, location);
storage = new S3Storage(region, bucket, endpoint, forcePathStyle, location);
}
export { storage };