diff options
author | Wim <wim@42.be> | 2017-11-04 14:55:25 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-11-04 14:55:25 +0100 |
commit | ba5649d2597c6d89f4c609d1246837f0172a722b (patch) | |
tree | 338221366e299c0902f4561eaeceaf6af57b6394 /bridge/helper/helper.go | |
parent | 1b305755100ded598dc416523a0d8813c76c5819 (diff) | |
download | matterbridge-msglm-ba5649d2597c6d89f4c609d1246837f0172a722b.tar.gz matterbridge-msglm-ba5649d2597c6d89f4c609d1246837f0172a722b.tar.bz2 matterbridge-msglm-ba5649d2597c6d89f4c609d1246837f0172a722b.zip |
Add helper
Diffstat (limited to 'bridge/helper/helper.go')
-rw-r--r-- | bridge/helper/helper.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go new file mode 100644 index 00000000..ecfc4df2 --- /dev/null +++ b/bridge/helper/helper.go @@ -0,0 +1,28 @@ +package helper + +import ( + "bytes" + "io" + "net/http" + "time" +) + +func DownloadFile(url string) (*[]byte, error) { + var buf bytes.Buffer + client := &http.Client{ + Timeout: time.Second * 5, + } + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + resp, err := client.Do(req) + if err != nil { + resp.Body.Close() + return nil, err + } + io.Copy(&buf, resp.Body) + data := buf.Bytes() + resp.Body.Close() + return &data, nil +} |