mirror of https://github.com/1Panel-dev/1Panel
feat: 腾讯 COS 支持大文件分片上传 (#2772)
parent
05029a3eda
commit
2d8a7bbbc3
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
cosSDK "github.com/tencentyun/cos-go-sdk-v5"
|
||||
|
@ -97,6 +98,27 @@ func (cos cosClient) Upload(src, target string) (bool, error) {
|
|||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
fileInfo, err := os.Stat(src)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if fileInfo.Size() > 5368709120 {
|
||||
opt := &cosSDK.MultiUploadOptions{
|
||||
OptIni: &cosSDK.InitiateMultipartUploadOptions{
|
||||
ACLHeaderOptions: nil,
|
||||
ObjectPutHeaderOptions: &cosSDK.ObjectPutHeaderOptions{
|
||||
XCosStorageClass: cos.scType,
|
||||
},
|
||||
},
|
||||
PartSize: 200,
|
||||
}
|
||||
if _, _, err := client.Object.MultiUpload(
|
||||
context.Background(), target, src, opt,
|
||||
); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
if _, err := client.Object.PutFromFile(context.Background(), target, src, &cosSDK.ObjectPutOptions{
|
||||
ACLHeaderOptions: nil,
|
||||
ObjectPutHeaderOptions: &cosSDK.ObjectPutHeaderOptions{
|
||||
|
|
|
@ -144,7 +144,7 @@ func TestAppToV2(t *testing.T) {
|
|||
}
|
||||
_ = fileOp.DeleteFile(newVersionDir + "/config.json")
|
||||
oldReadMefile := newVersionDir + "/README.md"
|
||||
_ = fileOp.Cut([]string{oldReadMefile}, newAppDir)
|
||||
// _ = fileOp.Cut([]string{oldReadMefile}, newAppDir)
|
||||
_ = fileOp.DeleteFile(oldReadMefile)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
{{ loadZero(dialogData.rowData?.hour) }} :
|
||||
{{ loadZero(dialogData.rowData?.minute) }}
|
||||
</span>
|
||||
<span v-if="dialogData.rowData?.specType === 'perDay'">
|
||||
{{ loadZero(dialogData.rowData?.hour) }} : {{ loadZero(dialogData.rowData?.minute) }}
|
||||
</span>
|
||||
<span v-if="dialogData.rowData?.specType === 'perWeek'">
|
||||
{{ loadWeek(dialogData.rowData?.week) }} {{ loadZero(dialogData.rowData?.hour) }} :
|
||||
{{ loadZero(dialogData.rowData?.minute) }}
|
||||
|
@ -127,7 +130,13 @@
|
|||
<el-row :gutter="20" v-show="hasRecords" class="mainRowClass">
|
||||
<el-col :span="6">
|
||||
<div class="infinite-list" style="overflow: auto">
|
||||
<el-table :data="records" border :show-header="false" @row-click="forDetail">
|
||||
<el-table
|
||||
style="cursor: pointer"
|
||||
:data="records"
|
||||
border
|
||||
:show-header="false"
|
||||
@row-click="forDetail"
|
||||
>
|
||||
<el-table-column>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.id === currentRecord.id" class="select-sign"></span>
|
||||
|
|
Loading…
Reference in New Issue