feat(s3): add setting for endpoint path style

This commit is contained in:
HFO4 2022-12-16 17:15:24 +08:00
parent f8eb1cd63e
commit 329db97568
5 changed files with 108 additions and 14 deletions

View File

@ -382,7 +382,7 @@
"createQiniuBucket": "Go to <0>Qiniu dashboard</0> to create a storage bucket.。",
"enterQiniuBucket": "Enter the \"bucket name\" you just created:",
"qiniuBucketName": "Bucket name",
"bucketTypeDes": "Select the type of bucket you just created. We recommend selecting \"Private bucket\" for higher security, private bucket does not support \"Get Source Link\" feature.",
"bucketTypeDes": "Select the type of bucket you just created. We recommend selecting \"Private bucket\" for higher security.",
"privateBucket": "Private bucket",
"publicBucket": "Public bucket",
"bucketCDNDes": "Fill in the CDN-accelerated domain name you have bound for the storage bucket.",
@ -552,7 +552,10 @@
"chunkSizeBytesDes": "Size of chunk for resumable uploads. Only supported in partial storage policy.",
"placeHolderWithSize": "Use placeholder before uploading",
"placeHolderWithSizeDes": "Whether to create a placeholder file before uploading .Only supported in partial storage policy.",
"saveChanges": "Save changes"
"saveChanges": "Save changes",
"s3EndpointPathStyle": "Select the format of the S3 Endpoint address, or if you don't know what to select, just leave to the default. Some third-party S3-compatible storage policies may require this option to work. When turned on, we will force to use of path-like format addresses, such as <0>http://s3.amazonaws.com/BUCKET/KEY</0>.",
"usePathEndpoint": "Force path style",
"useHostnameEndpoint": "Use host name if possible"
},
"node": {
"#": "#",

View File

@ -382,7 +382,7 @@
"createQiniuBucket": "前往 <0>七牛控制面板</0> 创建对象存储资源。",
"enterQiniuBucket": "在下方填写您在七牛创建存储空间时指定的“存储空间名称”:",
"qiniuBucketName": "存储空间名称",
"bucketTypeDes": "在下方选择您创建的空间类型,推荐选择“私有空间”以获得更高的安全性,私有空间无法开启“获取直链”功能。",
"bucketTypeDes": "在下方选择您创建的空间类型,推荐选择“私有空间”以获得更高的安全性。",
"privateBucket": "私有",
"publicBucket": "公有",
"bucketCDNDes": "填写您为存储空间绑定的 CDN 加速域名。",
@ -552,7 +552,10 @@
"chunkSizeBytesDes": "分片上传时单个分片的大小,仅部分存储策略支持",
"placeHolderWithSize": "上传前预支用户存储",
"placeHolderWithSizeDes": "是否在上传会话创建时就对用户存储进行预支,仅部分存储策略支持",
"saveChanges": "保存更改"
"saveChanges": "保存更改",
"s3EndpointPathStyle": "选择 S3 Endpoint 地址的格式,如果您不知道该选什么,保持默认即可。某些第三方 S3 兼容存储策略可能需要更改此选项。开启后,将会强制使用路径格式地址,比如 <0>http://s3.amazonaws.com/BUCKET/KEY</0>。",
"usePathEndpoint": "强制路径格式",
"useHostnameEndpoint": "主机名优先"
},
"node": {
"#": "#",

View File

@ -65,6 +65,10 @@ export default function EditPolicyPreload() {
.data.OptionsSerialized.placeholder_with_size
? "true"
: "false";
response.data.OptionsSerialized.s3_path_style = response.data
.OptionsSerialized.s3_path_style
? "true"
: "false";
response.data.OptionsSerialized.file_type = response.data
.OptionsSerialized.file_type

View File

@ -70,9 +70,10 @@ export default function EditPro(props) {
);
policyCopy.OptionsSerialized.placeholder_with_size =
policyCopy.OptionsSerialized.placeholder_with_size === "true";
policyCopy.OptionsSerialized.file_type = policyCopy.OptionsSerialized.file_type.split(
","
);
policyCopy.OptionsSerialized.s3_path_style =
policyCopy.OptionsSerialized.s3_path_style === "true";
policyCopy.OptionsSerialized.file_type =
policyCopy.OptionsSerialized.file_type.split(",");
if (
policyCopy.OptionsSerialized.file_type.length === 1 &&
policyCopy.OptionsSerialized.file_type[0] === ""
@ -640,6 +641,42 @@ export default function EditPro(props) {
</TableCell>
<TableCell>{t("odOnly")}</TableCell>
</TableRow>
<TableRow>
<TableCell component="th" scope="row">
{t("usePathEndpoint")}
</TableCell>
<TableCell>
<FormControl>
<RadioGroup
required
value={
policy.OptionsSerialized
.s3_path_style
}
onChange={handleOptionChange(
"s3_path_style"
)}
row
>
<FormControlLabel
value={"true"}
control={
<Radio color={"primary"} />
}
label={t("yes")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label={t("no")}
/>
</RadioGroup>
</FormControl>
</TableCell>
<TableCell>{t("s3Only")}</TableCell>
</TableRow>
</TableBody>
</Table>
<Button

View File

@ -176,6 +176,7 @@ export default function S3Guide(props) {
region: "us-east-2",
chunk_size: 25 << 20,
placeholder_with_size: "false",
s3_path_style: "true",
},
}
);
@ -233,9 +234,10 @@ export default function S3Guide(props) {
);
policyCopy.OptionsSerialized.placeholder_with_size =
policyCopy.OptionsSerialized.placeholder_with_size === "true";
policyCopy.OptionsSerialized.file_type = policyCopy.OptionsSerialized.file_type.split(
","
);
policyCopy.OptionsSerialized.s3_path_style =
policyCopy.OptionsSerialized.s3_path_style === "true";
policyCopy.OptionsSerialized.file_type =
policyCopy.OptionsSerialized.file_type.split(",");
if (
policyCopy.OptionsSerialized.file_type.length === 1 &&
policyCopy.OptionsSerialized.file_type[0] === ""
@ -421,6 +423,51 @@ export default function S3Guide(props) {
<div className={classes.stepNumberContainer}>
<div className={classes.stepNumber}>4</div>
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
<Trans
ns={"dashboard"}
i18nKey={"policy.s3EndpointPathStyle"}
components={[<code key={0} />]}
/>
</Typography>
<div className={classes.form}>
<FormControl required component="fieldset">
<RadioGroup
required
value={
policy.OptionsSerialized
.s3_path_style
}
onChange={handleOptionChange(
"s3_path_style"
)}
row
>
<FormControlLabel
value={"true"}
control={
<Radio color={"primary"} />
}
label={t("usePathEndpoint")}
/>
<FormControlLabel
value={"false"}
control={
<Radio color={"primary"} />
}
label={t("useHostnameEndpoint")}
/>
</RadioGroup>
</FormControl>
</div>
</div>
</div>
<div className={classes.subStepContainer}>
<div className={classes.stepNumberContainer}>
<div className={classes.stepNumber}>5</div>
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
{t("selectRegionDes")}
@ -455,7 +502,7 @@ export default function S3Guide(props) {
<div className={classes.subStepContainer}>
<div className={classes.stepNumberContainer}>
<div className={classes.stepNumber}>5</div>
<div className={classes.stepNumber}>6</div>
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
@ -494,7 +541,7 @@ export default function S3Guide(props) {
<Collapse in={useCDN === "true"}>
<div className={classes.subStepContainer}>
<div className={classes.stepNumberContainer}>
<div className={classes.stepNumber}>6</div>
<div className={classes.stepNumber}>7</div>
</div>
<div className={classes.subStepContent}>
<Typography variant={"body2"}>
@ -515,7 +562,7 @@ export default function S3Guide(props) {
<div className={classes.subStepContainer}>
<div className={classes.stepNumberContainer}>
<div className={classes.stepNumber}>
{getNumber(6, [useCDN === "true"])}
{getNumber(7, [useCDN === "true"])}
</div>
</div>
<div className={classes.subStepContent}>
@ -560,7 +607,7 @@ export default function S3Guide(props) {
<div className={classes.subStepContainer}>
<div className={classes.stepNumberContainer}>
<div className={classes.stepNumber}>
{getNumber(7, [useCDN === "true"])}
{getNumber(8, [useCDN === "true"])}
</div>
</div>
<div className={classes.subStepContent}>