added zipurlDownloader

This commit is contained in:
tzwang 2024-05-10 21:39:34 +08:00
parent 08fb7b3639
commit 6a5526289b
3 changed files with 1874 additions and 1829 deletions

View File

@ -1,12 +1,17 @@
package logic
import (
"archive/zip"
"bytes"
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-octopus/internal/common"
"gitlink.org.cn/JointCloud/pcm-octopus/internal/svc"
"gitlink.org.cn/JointCloud/pcm-octopus/octopus"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/jcce-pcm/utils/tool"
"io"
"log"
)
type DownloadAlgorithmUrlLogic struct {
@ -24,7 +29,36 @@ func NewDownloadAlgorithmUrlLogic(ctx context.Context, svcCtx *svc.ServiceContex
}
func (l *DownloadAlgorithmUrlLogic) DownloadAlgorithmUrl(in *octopus.AlgorithmUrlReq) (*octopus.AlgorithmUrlResp, error) {
// todo: add your logic here and delete this line
resp := &octopus.AlgorithmUrlResp{}
return &octopus.AlgorithmUrlResp{}, nil
token := common.GetToken(in.Platform)
if token == "" {
log.Println("获取token失败, platform : ", in.Platform)
return nil, errors.New("获取token失败")
}
req := tool.GetACHttpRequest()
rs, err := req.
SetHeader("token", token).
Get(in.Url)
if err != nil {
return nil, err
}
file := rs.Body()
reader, _ := zip.NewReader(bytes.NewReader(file), int64(len(file)))
zf := &zip.File{}
for _, f := range reader.File {
if f.FileInfo().IsDir() {
continue
}
zf = f
}
rc, _ := zf.Open()
all, err := io.ReadAll(rc)
if err != nil {
return nil, err
}
resp.Algorithm = string(all)
return resp, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -76,7 +76,8 @@ message PayloadDownloadAlgorithm{
}
message AlgorithmUrlReq {
string url = 1;
string platform =1;
string url = 2;
}
message AlgorithmUrlResp {