MCPcopy Index your code
hub / github.com/1Panel-dev/1Panel / DownloadFileWithProxy

Function DownloadFileWithProxy

agent/utils/files/utils.go:332–350  ·  view source on GitHub ↗
(url, dst string)

Source from the content-addressed store, hash-verified

330}
331
332func DownloadFileWithProxy(url, dst string) error {
333 resp, cancel, err := req_helper.RequestFile(url, http.MethodGet, constant.TimeOut5m)
334 if err != nil {
335 return err
336 }
337 defer cancel()
338 defer resp.Close()
339
340 out, err := os.Create(dst)
341 if err != nil {
342 return fmt.Errorf("create download file [%s] error, err %s", dst, err.Error())
343 }
344 defer out.Close()
345
346 if _, err = io.Copy(out, resp); err != nil {
347 return fmt.Errorf("save download file [%s] error, err %s", dst, err.Error())
348 }
349 return nil
350}
351
352func GetDecoderByName(name string) encoding.Encoding {
353 switch strings.ToLower(name) {

Callers

nothing calls this directly

Calls 4

CopyMethod · 0.80
CloseMethod · 0.65
CreateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected