Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming
2023-11-20 17:16:31 +08:00
8 changed files with 106 additions and 0 deletions

View File

@@ -25,4 +25,12 @@ type Config struct {
Version string
Urls []string
}
AliyunOSS struct {
Endpoint string `json:"endpoint"`
AccessKeyId string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
BucketName string `json:"bucket_name"`
BucketUrl string `json:"bucket_url"`
BasePath string `json:"base_path"`
}
}

View File

@@ -7,6 +7,7 @@ import (
"fusenapi/utils/hash"
"io"
"net/http"
"time"
"context"
@@ -106,6 +107,20 @@ func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendR
return resp.SetStatus(basic.CodeFileUploadErr, "upload file failed")
}
// 是否备份--异步任务
if req.BackupType != "" {
upload.UploadType = "oss"
upload.AliyunOSS.Endpoint = l.svcCtx.Config.AliyunOSS.Endpoint
upload.AliyunOSS.AccessKeyId = l.svcCtx.Config.AliyunOSS.AccessKeyId
upload.AliyunOSS.AccessKeySecret = l.svcCtx.Config.AliyunOSS.AccessKeySecret
upload.AliyunOSS.BucketName = l.svcCtx.Config.AliyunOSS.BucketName
upload.AliyunOSS.BucketUrl = l.svcCtx.Config.AliyunOSS.BucketUrl
upload.AliyunOSS.BasePath = l.svcCtx.Config.AliyunOSS.BasePath
time.AfterFunc(time.Second*1, func() {
err = upload.UploadFileByUrl(resourceId, uploadRes.ResourceUrl)
})
}
// 返回成功的响应和上传URL
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"upload_data": UploadUrl{

View File

@@ -5,6 +5,7 @@ import (
"fusenapi/utils/basic"
"fusenapi/utils/file"
"fusenapi/utils/hash"
"time"
"context"
@@ -88,6 +89,20 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri
return resp.SetStatus(basic.CodeFileUploadErr, "upload file failed")
}
// 是否备份--异步任务
if req.BackupType != "" {
upload.UploadType = "oss"
upload.AliyunOSS.Endpoint = l.svcCtx.Config.AliyunOSS.Endpoint
upload.AliyunOSS.AccessKeyId = l.svcCtx.Config.AliyunOSS.AccessKeyId
upload.AliyunOSS.AccessKeySecret = l.svcCtx.Config.AliyunOSS.AccessKeySecret
upload.AliyunOSS.BucketName = l.svcCtx.Config.AliyunOSS.BucketName
upload.AliyunOSS.BucketUrl = l.svcCtx.Config.AliyunOSS.BucketUrl
upload.AliyunOSS.BasePath = l.svcCtx.Config.AliyunOSS.BasePath
time.AfterFunc(time.Second*1, func() {
err = upload.UploadFileByUrl(resourceId, uploadRes.ResourceUrl)
})
}
// 返回成功的响应和上传URL
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"upload_data": UploadUrl{

View File

@@ -38,6 +38,7 @@ type UploadFileBaseReq struct {
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
BackupType string `form:"backup_type,optional"` // 备份资源
}
type UploadLogoDebugReq struct {
@@ -63,6 +64,7 @@ type UploadFileBackendReq struct {
Source string `form:"source"` // 上传来源
Refresh int64 `form:"refresh,optional"` // 强制更新 10
ResourceId string `form:"resource_id,optional"` // 资源ID
BackupType string `form:"backup_type,optional"` // 备份资源
}
type UploadFilesReq struct {