MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / downloadData

Function downloadData

plugin/draw/draw.go:463–479  ·  view source on GitHub ↗

下载数据,url=dataurl+path[5:]+"?inline=true"

(path, url string)

Source from the content-addressed store, hash-verified

461
462// 下载数据,url=dataurl+path[5:]+"?inline=true"
463func downloadData(path, url string) error {
464 data, err := web.RequestDataWith(web.NewTLS12Client(), url, "GET", "gitcode.net", web.RandUA(), nil)
465 if err != nil {
466 return errors.New("下载" + url + "失败!")
467 }
468 logrus.Printf("[file]从镜像下载数据%d字节...", len(data))
469 if len(data) == 0 {
470 return errors.New("read body len <= 0")
471 }
472 // 写入数据
473 err = os.WriteFile(path, data, 0644)
474 if err != nil {
475 return err
476 }
477 logrus.Printf("[file]下载文件成功")
478 return nil
479}

Callers 1

loadpicMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected