parent
a4027c4271
commit
d3f19c58d7
2 changed files with 21 additions and 17 deletions
@ -0,0 +1,20 @@ |
||||
package utils |
||||
|
||||
import ( |
||||
"fmt" |
||||
"io" |
||||
"net/http" |
||||
) |
||||
|
||||
func DownloadFile(url string) (io.ReadCloser, error) { |
||||
response, err := http.Get(url) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
if response.StatusCode != 200 { |
||||
return nil, fmt.Errorf("Not able to download %s", url) |
||||
} |
||||
|
||||
return response.Body, nil |
||||
} |
Loading…
Reference in new issue