mirror of https://github.com/1Panel-dev/1Panel
parent
730a25fcd2
commit
afd4c8486a
|
@ -2,6 +2,7 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||||
|
@ -12,6 +13,7 @@ import (
|
||||||
type kodoClient struct {
|
type kodoClient struct {
|
||||||
bucket string
|
bucket string
|
||||||
domain string
|
domain string
|
||||||
|
timeout string
|
||||||
auth *auth.Credentials
|
auth *auth.Credentials
|
||||||
client *storage.BucketManager
|
client *storage.BucketManager
|
||||||
}
|
}
|
||||||
|
@ -21,14 +23,17 @@ func NewKodoClient(vars map[string]interface{}) (*kodoClient, error) {
|
||||||
secretKey := loadParamFromVars("secretKey", vars)
|
secretKey := loadParamFromVars("secretKey", vars)
|
||||||
bucket := loadParamFromVars("bucket", vars)
|
bucket := loadParamFromVars("bucket", vars)
|
||||||
domain := loadParamFromVars("domain", vars)
|
domain := loadParamFromVars("domain", vars)
|
||||||
|
timeout := loadParamFromVars("timeout", vars)
|
||||||
|
if timeout == "" {
|
||||||
|
timeout = "1"
|
||||||
|
}
|
||||||
conn := auth.New(accessKey, secretKey)
|
conn := auth.New(accessKey, secretKey)
|
||||||
cfg := storage.Config{
|
cfg := storage.Config{
|
||||||
UseHTTPS: false,
|
UseHTTPS: false,
|
||||||
}
|
}
|
||||||
bucketManager := storage.NewBucketManager(conn, &cfg)
|
bucketManager := storage.NewBucketManager(conn, &cfg)
|
||||||
|
|
||||||
return &kodoClient{client: bucketManager, auth: conn, bucket: bucket, domain: domain}, nil
|
return &kodoClient{client: bucketManager, auth: conn, bucket: bucket, domain: domain, timeout: timeout}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k kodoClient) ListBuckets() ([]interface{}, error) {
|
func (k kodoClient) ListBuckets() ([]interface{}, error) {
|
||||||
|
@ -66,8 +71,13 @@ func (k kodoClient) Delete(path string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k kodoClient) Upload(src, target string) (bool, error) {
|
func (k kodoClient) Upload(src, target string) (bool, error) {
|
||||||
|
|
||||||
|
int64Value, _ := strconv.ParseInt(k.timeout, 10, 64)
|
||||||
|
unixTimestamp := int64Value * 3600
|
||||||
|
|
||||||
putPolicy := storage.PutPolicy{
|
putPolicy := storage.PutPolicy{
|
||||||
Scope: k.bucket,
|
Scope: k.bucket,
|
||||||
|
Expires: uint64(unixTimestamp),
|
||||||
}
|
}
|
||||||
upToken := putPolicy.UploadToken(k.auth)
|
upToken := putPolicy.UploadToken(k.auth)
|
||||||
cfg := storage.Config{UseHTTPS: true, UseCdnDomains: false}
|
cfg := storage.Config{UseHTTPS: true, UseCdnDomains: false}
|
||||||
|
|
|
@ -917,6 +917,9 @@ const message = {
|
||||||
errPath: 'Backup path [{0}] error, cannot download!',
|
errPath: 'Backup path [{0}] error, cannot download!',
|
||||||
cutWebsiteLog: 'Cut Website Log',
|
cutWebsiteLog: 'Cut Website Log',
|
||||||
cutWebsiteLogHelper: 'The cut log files will be backed up to the backup directory of 1Panel',
|
cutWebsiteLogHelper: 'The cut log files will be backed up to the backup directory of 1Panel',
|
||||||
|
|
||||||
|
requestExpirationTime: 'Upload Request Expiration Time',
|
||||||
|
unitHours: 'Unit: Hours',
|
||||||
},
|
},
|
||||||
monitor: {
|
monitor: {
|
||||||
monitor: 'Monitor',
|
monitor: 'Monitor',
|
||||||
|
|
|
@ -873,6 +873,9 @@ const message = {
|
||||||
errPath: '備份路徑 [{0}] 錯誤,無法下載!',
|
errPath: '備份路徑 [{0}] 錯誤,無法下載!',
|
||||||
cutWebsiteLog: '切割網站日誌',
|
cutWebsiteLog: '切割網站日誌',
|
||||||
cutWebsiteLogHelper: '切割的日誌文件會備份到 1Panel 的 backup 目錄下',
|
cutWebsiteLogHelper: '切割的日誌文件會備份到 1Panel 的 backup 目錄下',
|
||||||
|
|
||||||
|
requestExpirationTime: '上傳請求過期時間',
|
||||||
|
unitHours: '單位:小時',
|
||||||
},
|
},
|
||||||
monitor: {
|
monitor: {
|
||||||
monitor: '監控',
|
monitor: '監控',
|
||||||
|
|
|
@ -874,6 +874,9 @@ const message = {
|
||||||
errPath: '备份路径 [{0}] 错误,无法下载!',
|
errPath: '备份路径 [{0}] 错误,无法下载!',
|
||||||
cutWebsiteLog: '切割网站日志',
|
cutWebsiteLog: '切割网站日志',
|
||||||
cutWebsiteLogHelper: '切割的日志文件会备份到 1Panel 的 backup 目录下',
|
cutWebsiteLogHelper: '切割的日志文件会备份到 1Panel 的 backup 目录下',
|
||||||
|
|
||||||
|
requestExpirationTime: '上传请求过期时间',
|
||||||
|
unitHours: '单位:小时',
|
||||||
},
|
},
|
||||||
monitor: {
|
monitor: {
|
||||||
monitor: '监控',
|
monitor: '监控',
|
||||||
|
|
|
@ -49,6 +49,18 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
<span v-if="errBuckets" class="input-error">{{ $t('commons.rule.requiredSelect') }}</span>
|
<span v-if="errBuckets" class="input-error">{{ $t('commons.rule.requiredSelect') }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item :label="$t('cronjob.requestExpirationTime')" prop="varsJson.timeout">
|
||||||
|
<el-input-number
|
||||||
|
style="width: 200px"
|
||||||
|
:min="1"
|
||||||
|
step-strictly
|
||||||
|
:step="1"
|
||||||
|
v-model.number="kodoData.rowData!.varsJson['timeout']"
|
||||||
|
></el-input-number>
|
||||||
|
<span class="input-help">{{ $t('cronjob.unitHours') }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('setting.backupDir')" prop="backupPath">
|
<el-form-item :label="$t('setting.backupDir')" prop="backupPath">
|
||||||
<el-input clearable v-model.trim="kodoData.rowData!.backupPath" placeholder="/1panel" />
|
<el-input clearable v-model.trim="kodoData.rowData!.backupPath" placeholder="/1panel" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -107,6 +119,9 @@ const acceptParams = (params: DialogProps): void => {
|
||||||
domainProto.value = httpItem.proto;
|
domainProto.value = httpItem.proto;
|
||||||
}
|
}
|
||||||
title.value = i18n.global.t('commons.button.' + kodoData.value.title);
|
title.value = i18n.global.t('commons.button.' + kodoData.value.title);
|
||||||
|
if (kodoData.value.rowData!.varsJson['timeout'] === undefined) {
|
||||||
|
kodoData.value.rowData!.varsJson['timeout'] = 1;
|
||||||
|
}
|
||||||
drawerVisible.value = true;
|
drawerVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue