From afd4c8486a3098d265d7836d66cb070be41870a2 Mon Sep 17 00:00:00 2001
From: John Bro <42930107+john1298308460@users.noreply.github.com>
Date: Wed, 10 Jul 2024 18:07:26 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=83=E7=89=9B=E4=BA=91=E5=A4=87?=
=?UTF-8?q?=E4=BB=BD=E8=B4=A6=E5=8F=B7=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE?=
=?UTF-8?q?=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=20(#5745)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Refs #4330
---
backend/utils/cloud_storage/client/kodo.go | 24 +++++++++++++------
frontend/src/lang/modules/en.ts | 3 +++
frontend/src/lang/modules/tw.ts | 3 +++
frontend/src/lang/modules/zh.ts | 3 +++
.../setting/backup-account/kodo/index.vue | 15 ++++++++++++
5 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/backend/utils/cloud_storage/client/kodo.go b/backend/utils/cloud_storage/client/kodo.go
index 488f72b77..d1fcf28eb 100644
--- a/backend/utils/cloud_storage/client/kodo.go
+++ b/backend/utils/cloud_storage/client/kodo.go
@@ -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}
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 1c18372dc..05abc7e01 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -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',
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index ddce60a0c..f29d8b0bd 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -873,6 +873,9 @@ const message = {
errPath: '備份路徑 [{0}] 錯誤,無法下載!',
cutWebsiteLog: '切割網站日誌',
cutWebsiteLogHelper: '切割的日誌文件會備份到 1Panel 的 backup 目錄下',
+
+ requestExpirationTime: '上傳請求過期時間',
+ unitHours: '單位:小時',
},
monitor: {
monitor: '監控',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index efed10dcf..88a77f1b0 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -874,6 +874,9 @@ const message = {
errPath: '备份路径 [{0}] 错误,无法下载!',
cutWebsiteLog: '切割网站日志',
cutWebsiteLogHelper: '切割的日志文件会备份到 1Panel 的 backup 目录下',
+
+ requestExpirationTime: '上传请求过期时间',
+ unitHours: '单位:小时',
},
monitor: {
monitor: '监控',
diff --git a/frontend/src/views/setting/backup-account/kodo/index.vue b/frontend/src/views/setting/backup-account/kodo/index.vue
index 2e715260c..a7431e549 100644
--- a/frontend/src/views/setting/backup-account/kodo/index.vue
+++ b/frontend/src/views/setting/backup-account/kodo/index.vue
@@ -49,6 +49,18 @@
{{ $t('commons.rule.requiredSelect') }}
+
+
+
+ {{ $t('cronjob.unitHours') }}
+
+
@@ -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;
};