Merge branch 'master' of https://github.com/Victrid/remotely-save into Victrid-master

This commit is contained in:
fyears 2022-03-20 23:37:26 +08:00
commit ac4eff376d
5 changed files with 29 additions and 1 deletions

View File

@ -15,6 +15,7 @@ export interface S3Config {
s3BucketName: string; s3BucketName: string;
bypassCorsLocally?: boolean; bypassCorsLocally?: boolean;
partsConcurrency?: number; partsConcurrency?: number;
forcePathStyle?: boolean;
} }
export interface DropboxConfig { export interface DropboxConfig {

@ -1 +1 @@
Subproject commit 4b69d60d8956f2c2bb9e642e2524d6f2404c2e24 Subproject commit 28730585f8cef9625b2b5a2296318c1c071ff7ba

View File

@ -658,6 +658,9 @@ export default class RemotelySavePlugin extends Plugin {
if (this.settings.s3.partsConcurrency === undefined) { if (this.settings.s3.partsConcurrency === undefined) {
this.settings.s3.partsConcurrency = 20; this.settings.s3.partsConcurrency = 20;
} }
if (this.settings.s3.forcePathStyle === undefined) {
this.settings.s3.forcePathStyle = false;
}
} }
async saveSettings() { async saveSettings() {

View File

@ -155,6 +155,7 @@ export const DEFAULT_S3_CONFIG = {
s3BucketName: "", s3BucketName: "",
bypassCorsLocally: true, bypassCorsLocally: true,
partsConcurrency: 20, partsConcurrency: 20,
forcePathStyle: false,
}; };
export type S3ObjectType = _Object; export type S3ObjectType = _Object;
@ -192,6 +193,7 @@ export const getS3Client = (s3Config: S3Config) => {
const s3Client = new S3Client({ const s3Client = new S3Client({
region: s3Config.s3Region, region: s3Config.s3Region,
endpoint: endpoint, endpoint: endpoint,
forcePathStyle: s3Config.forcePathStyle,
credentials: { credentials: {
accessKeyId: s3Config.s3AccessKeyID, accessKeyId: s3Config.s3AccessKeyID,
secretAccessKey: s3Config.s3SecretAccessKey, secretAccessKey: s3Config.s3SecretAccessKey,
@ -203,6 +205,7 @@ export const getS3Client = (s3Config: S3Config) => {
const s3Client = new S3Client({ const s3Client = new S3Client({
region: s3Config.s3Region, region: s3Config.s3Region,
endpoint: endpoint, endpoint: endpoint,
forcePathStyle: s3Config.forcePathStyle,
credentials: { credentials: {
accessKeyId: s3Config.s3AccessKeyID, accessKeyId: s3Config.s3AccessKeyID,
secretAccessKey: s3Config.s3SecretAccessKey, secretAccessKey: s3Config.s3SecretAccessKey,

View File

@ -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)) { if (requireApiVersion(API_VER_REQURL)) {
new Setting(s3Div) new Setting(s3Div)
.setName(t("settings_s3_bypasscorslocally")) .setName(t("settings_s3_bypasscorslocally"))