diff --git a/src/baseTypes.ts b/src/baseTypes.ts index c9ab8ae..7a4d9c9 100644 --- a/src/baseTypes.ts +++ b/src/baseTypes.ts @@ -15,6 +15,7 @@ export interface S3Config { s3BucketName: string; bypassCorsLocally?: boolean; partsConcurrency?: number; + forcePathStyle?: boolean; } export interface DropboxConfig { diff --git a/src/langs b/src/langs index 4b69d60..2873058 160000 --- a/src/langs +++ b/src/langs @@ -1 +1 @@ -Subproject commit 4b69d60d8956f2c2bb9e642e2524d6f2404c2e24 +Subproject commit 28730585f8cef9625b2b5a2296318c1c071ff7ba diff --git a/src/main.ts b/src/main.ts index 97b54cd..4c9d018 100644 --- a/src/main.ts +++ b/src/main.ts @@ -658,6 +658,9 @@ export default class RemotelySavePlugin extends Plugin { if (this.settings.s3.partsConcurrency === undefined) { this.settings.s3.partsConcurrency = 20; } + if (this.settings.s3.forcePathStyle === undefined) { + this.settings.s3.forcePathStyle = false; + } } async saveSettings() { diff --git a/src/remoteForS3.ts b/src/remoteForS3.ts index e07a3ba..6e4f4a6 100644 --- a/src/remoteForS3.ts +++ b/src/remoteForS3.ts @@ -155,6 +155,7 @@ export const DEFAULT_S3_CONFIG = { s3BucketName: "", bypassCorsLocally: true, partsConcurrency: 20, + forcePathStyle: false, }; export type S3ObjectType = _Object; @@ -192,6 +193,7 @@ export const getS3Client = (s3Config: S3Config) => { const s3Client = new S3Client({ region: s3Config.s3Region, endpoint: endpoint, + forcePathStyle: s3Config.forcePathStyle, credentials: { accessKeyId: s3Config.s3AccessKeyID, secretAccessKey: s3Config.s3SecretAccessKey, @@ -203,6 +205,7 @@ export const getS3Client = (s3Config: S3Config) => { const s3Client = new S3Client({ region: s3Config.s3Region, endpoint: endpoint, + forcePathStyle: s3Config.forcePathStyle, credentials: { accessKeyId: s3Config.s3AccessKeyID, secretAccessKey: s3Config.s3SecretAccessKey, diff --git a/src/settings.ts b/src/settings.ts index c7d688f..32f217c 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -745,6 +745,27 @@ export class RemotelySaveSettingTab extends PluginSettingTab { }) ); + new Setting(s3Div) + .setName(t("settings_s3_urlstyle")) + .setDesc(t("settings_s3_urlstyle_desc")) + .addDropdown((dropdown) => { + dropdown.addOption( + "virtualHostedStyle", + "Virtual Hosted-Style (default)" + ); + dropdown.addOption("pathStyle", "Path-Style"); + dropdown + .setValue( + this.plugin.settings.s3.forcePathStyle + ? "pathStyle" + : "virtualHostedStyle" + ) + .onChange(async (val: string) => { + this.plugin.settings.s3.forcePathStyle = val === "pathStyle"; + await this.plugin.saveSettings(); + }); + }); + if (requireApiVersion(API_VER_REQURL)) { new Setting(s3Div) .setName(t("settings_s3_bypasscorslocally"))