MCPcopy Create free account
hub / github.com/devld/go-drive / downloadFile

Function downloadFile

drive/script/script_utils.go:195–212  ·  view source on GitHub ↗
(ctx context.Context, url string, name string)

Source from the content-addressed store, hash-verified

193}
194
195func downloadFile(ctx context.Context, url string, name string) error {
196 req, e := http.NewRequestWithContext(ctx, "GET", url, nil)
197 if e != nil {
198 return e
199 }
200 resp, e := http.DefaultClient.Do(req)
201 if e != nil {
202 return e
203 }
204 defer func() { _ = resp.Body.Close() }()
205 f, e := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
206 if e != nil {
207 return e
208 }
209 defer func() { _ = f.Close() }()
210 _, e = io.Copy(f, resp.Body)
211 return e
212}
213
214func ListDriveScripts(config common.Config) ([]DriveScript, error) {
215 scriptsPath, _ := config.GetDir(config.DrivesDir, false)

Callers 1

InstallDriveScriptFunction · 0.85

Calls 3

CloseMethod · 0.65
OpenFileMethod · 0.65
CopyMethod · 0.65

Tested by

no test coverage detected