mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 15:13:05 +00:00
Implement S3 force path-style support
This commit is contained in:
1 parent
d9d339882b
commit
50c7da9872
2 files changed
+10
-2
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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 };
|
||||
Reference in new issue
Block a user