新增阿里云OSS上传文件逻辑

This commit is contained in:
momo 2023-11-20 14:48:54 +08:00
parent 138b0d0c4e
commit fea04f12d7
2 changed files with 15 additions and 15 deletions

View File

@ -109,18 +109,18 @@ func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendR
// 是否备份--异步任务
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() {
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
err = upload.UploadFileByUrl(resourceId, uploadRes.ResourceUrl)
})
}
// 返回成功的响应和上传URL
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"upload_data": UploadUrl{

View File

@ -91,14 +91,14 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri
// 是否备份--异步任务
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() {
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
err = upload.UploadFileByUrl(resourceId, uploadRes.ResourceUrl)
})