Skip to content

Commit

Permalink
fixes images really
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Fricke committed Aug 30, 2021
1 parent 63f7de2 commit 357e4ec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions helper/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@ import (
func HTTPDownload(uri string) ([]byte, error) {
res, err := http.Get(uri)
if err != nil {
return nil, err
}
defer res.Body.Close()
d, err := ioutil.ReadAll(res.Body)
if err != nil {
}
return d, err
}

func HTTPDownloadWithToken(uri string, token string) ([]byte, error) {
req, err := http.NewRequest("GET", uri, nil)
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Bearer " + token)
client := http.Client{}
res, err := client.Do(req)
defer res.Body.Close()
d, err := ioutil.ReadAll(res.Body)
if err != nil {
}
return d, err
}
2 changes: 1 addition & 1 deletion slack/slack_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c Client) mapAttachments(attachments []slack.File) []model.Attachment {
if len(url) <= 0 {
url = attachment.URLPrivateDownload
}
download, err := helper.HTTPDownload(url)
download, err := helper.HTTPDownloadWithToken(url, c.Token)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 357e4ec

Please sign in to comment.