summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bridge/helper/helper.go28
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
+}