MCPcopy Index your code
hub / github.com/devspace-sh/devspace / downloadFile

Function downloadFile

pkg/devspace/services/inject/inject.go:225–250  ·  view source on GitHub ↗
(version string, filepath string, filename string)

Source from the content-addressed store, hash-verified

223}
224
225func downloadFile(version string, filepath string, filename string) error {
226 // Create download url
227 url, err := devSpaceHelperDownloadURL(version, filename)
228 if err != nil {
229 return errors.Wrap(err, "find download URL")
230 }
231
232 out, err := os.Create(filepath)
233 if err != nil {
234 return errors.Wrap(err, "create filepath")
235 }
236 defer out.Close()
237
238 resp, err := http.Get(url)
239 if err != nil {
240 return errors.Wrap(err, "download devspace helper")
241 }
242 defer resp.Body.Close()
243
244 _, err = io.Copy(out, resp.Body)
245 if err != nil {
246 return errors.Wrap(err, "download devspace helper to file")
247 }
248
249 return nil
250}
251
252type helperFileInfo []byte
253

Callers 1

downloadSyncHelperFunction · 0.70

Calls 4

CloseMethod · 0.65
CopyMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected