MCPcopy
hub / github.com/koderover/zadig / Download

Function Download

pkg/cli/zadig-agent/util/client/client.go:74–93  ·  view source on GitHub ↗

Download retrieves content from the given url and write it to path.

(url, path string, rfs ...RequestFunc)

Source from the content-addressed store, hash-verified

72
73// Download retrieves content from the given url and write it to path.
74func Download(url, path string, rfs ...RequestFunc) error {
75 // download may take more time
76 cl := New(UnsetTimeout())
77 res, err := cl.Get(url, rfs...)
78 if err != nil {
79 return err
80 }
81
82 f, err := os.Create(path)
83 if err != nil {
84 return err
85 }
86 defer func() {
87 _ = f.Close()
88 }()
89
90 _, err = io.Copy(f, bytes.NewReader(res.Body()))
91
92 return err
93}
94
95// New TODO: need to config tls security
96func New(cfs ...ClientFunc) *Client {

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
UnsetTimeoutFunction · 0.70
GetMethod · 0.65
CreateMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected