MCPcopy
hub / github.com/iron-io/functions / downloadToFile

Function downloadToFile

fn/commands/lambda.go:237–257  ·  view source on GitHub ↗
(url string)

Source from the content-addressed store, hash-verified

235}
236
237func downloadToFile(url string) (string, error) {
238 downloadResp, err := http.Get(url)
239 if err != nil {
240 return "", err
241 }
242 defer downloadResp.Body.Close()
243
244 // zip reader needs ReaderAt, hence the indirection.
245 tmpFile, err := ioutil.TempFile("", "lambda-function-")
246 if err != nil {
247 return "", err
248 }
249
250 if _, err := io.Copy(tmpFile, downloadResp.Body); err != nil {
251 return "", err
252 }
253 if err := tmpFile.Close(); err != nil {
254 return "", err
255 }
256 return tmpFile.Name(), nil
257}
258
259func unzipAndGetTopLevelFiles(dst, src string) (files []fileLike, topErr error) {
260 files = make([]fileLike, 0)

Callers 1

awsImportFunction · 0.85

Calls 2

CloseMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…