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

Function downloadAndSave

plugin/cybercat/catdata.go:143–155  ·  view source on GitHub ↗

downloadAndSave 下载图片并保存到本地

(url, filepath string)

Source from the content-addressed store, hash-verified

141
142// downloadAndSave 下载图片并保存到本地
143func downloadAndSave(url, filepath string) error {
144 data, err := web.GetData(url)
145 if err != nil {
146 return err
147 }
148 f, err := os.Create(filepath)
149 if err != nil {
150 return err
151 }
152 defer f.Close()
153 _, err = f.Write(data)
154 return err
155}
156
157// getCatAPIKey API密钥
158func getCatAPIKey() string {

Callers 1

avatarMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected