refactor(workflow): 统一 OSS 接口并重构恢复锁
- 将文件地址前缀与上传逻辑迁移至 common/oss - 恢复执行改用 utils.WithLock 自动续期锁 - 转写提示词增加单镜头最小时长约束
This commit is contained in:
@@ -9,8 +9,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
commonHttp "gitea.redpowerfuture.com/red-future/common/http"
|
||||
"gitea.redpowerfuture.com/red-future/common/utils"
|
||||
"gitea.redpowerfuture.com/red-future/common/oss"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
@@ -260,7 +259,7 @@ func GenerateImageLambda(ctx context.Context, input any) (any, error) {
|
||||
items = append(items, s)
|
||||
}
|
||||
}
|
||||
imgAddressPrefix, err := utils.GetFileAddressPrefix(ctx)
|
||||
imgAddressPrefix, err := oss.GetFileAddressPrefix(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -393,17 +392,18 @@ func getImageBytesFromURL(url string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func Upload(ctx context.Context, req *dto.UploadFileBytesReq) (*dto.UploadFileBytesRes, error) {
|
||||
headers := make(map[string]string)
|
||||
if r := g.RequestFromCtx(ctx); r != nil {
|
||||
for k, v := range r.Header {
|
||||
headers[k] = v[0]
|
||||
}
|
||||
}
|
||||
res := &dto.UploadFileBytesRes{}
|
||||
err := commonHttp.Post(ctx, "oss/file/uploadFileBytes", headers, res, req)
|
||||
// 统一走 common/oss:旧实现 POST oss/file/uploadFileBytes 是坏链(oss 服务从未注册该路由,必然 404),
|
||||
// common/oss 打真实 oss/file/uploadFile,且 multipart field=file、X-User-Info 注入与旧透传等价
|
||||
res, err := oss.UploadFileBytes(ctx, req.FileName, req.FileBytes)
|
||||
if err != nil {
|
||||
glog.Error(ctx, err)
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
return &dto.UploadFileBytesRes{
|
||||
FileURL: res.FileURL,
|
||||
FileSize: res.FileSize,
|
||||
FileName: res.FileName,
|
||||
FileFormat: res.FileFormat,
|
||||
FileAddressPrefix: res.FileAddressPrefix,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user