mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-06 22:09:05 +08:00
parent
730a25fcd2
commit
afd4c8486a
@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||
@ -10,10 +11,11 @@ import (
|
||||
)
|
||||
|
||||
type kodoClient struct {
|
||||
bucket string
|
||||
domain string
|
||||
auth *auth.Credentials
|
||||
client *storage.BucketManager
|
||||
bucket string
|
||||
domain string
|
||||
timeout string
|
||||
auth *auth.Credentials
|
||||
client *storage.BucketManager
|
||||
}
|
||||
|
||||
func NewKodoClient(vars map[string]interface{}) (*kodoClient, error) {
|
||||
@ -21,14 +23,17 @@ func NewKodoClient(vars map[string]interface{}) (*kodoClient, error) {
|
||||
secretKey := loadParamFromVars("secretKey", vars)
|
||||
bucket := loadParamFromVars("bucket", vars)
|
||||
domain := loadParamFromVars("domain", vars)
|
||||
|
||||
timeout := loadParamFromVars("timeout", vars)
|
||||
if timeout == "" {
|
||||
timeout = "1"
|
||||
}
|
||||
conn := auth.New(accessKey, secretKey)
|
||||
cfg := storage.Config{
|
||||
UseHTTPS: false,
|
||||
}
|
||||
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) {
|
||||
@ -66,8 +71,13 @@ func (k kodoClient) Delete(path 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{
|
||||
Scope: k.bucket,
|
||||
Scope: k.bucket,
|
||||
Expires: uint64(unixTimestamp),
|
||||
}
|
||||
upToken := putPolicy.UploadToken(k.auth)
|
||||
cfg := storage.Config{UseHTTPS: true, UseCdnDomains: false}
|
||||
|
@ -917,6 +917,9 @@ const message = {
|
||||
errPath: 'Backup path [{0}] error, cannot download!',
|
||||
cutWebsiteLog: 'Cut Website Log',
|
||||
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',
|
||||
|
@ -873,6 +873,9 @@ const message = {
|
||||
errPath: '備份路徑 [{0}] 錯誤,無法下載!',
|
||||
cutWebsiteLog: '切割網站日誌',
|
||||
cutWebsiteLogHelper: '切割的日誌文件會備份到 1Panel 的 backup 目錄下',
|
||||
|
||||
requestExpirationTime: '上傳請求過期時間',
|
||||
unitHours: '單位:小時',
|
||||
},
|
||||
monitor: {
|
||||
monitor: '監控',
|
||||
|
@ -874,6 +874,9 @@ const message = {
|
||||
errPath: '备份路径 [{0}] 错误,无法下载!',
|
||||
cutWebsiteLog: '切割网站日志',
|
||||
cutWebsiteLogHelper: '切割的日志文件会备份到 1Panel 的 backup 目录下',
|
||||
|
||||
requestExpirationTime: '上传请求过期时间',
|
||||
unitHours: '单位:小时',
|
||||
},
|
||||
monitor: {
|
||||
monitor: '监控',
|
||||
|
@ -49,6 +49,18 @@
|
||||
</el-button>
|
||||
<span v-if="errBuckets" class="input-error">{{ $t('commons.rule.requiredSelect') }}</span>
|
||||
</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-input clearable v-model.trim="kodoData.rowData!.backupPath" placeholder="/1panel" />
|
||||
</el-form-item>
|
||||
@ -107,6 +119,9 @@ const acceptParams = (params: DialogProps): void => {
|
||||
domainProto.value = httpItem.proto;
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user