Skip to content

Commit

Permalink
change ReadAll to Copy on downloadMedia
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoferreiras committed Nov 16, 2023
1 parent 29c6905 commit 24f5d3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion download.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package whatsmeow

import (
"bytes"
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
Expand Down Expand Up @@ -303,7 +304,9 @@ func (cli *Client) downloadMedia(url string) ([]byte, error) {
if resp.StatusCode != http.StatusOK {
return nil, DownloadHTTPError{Response: resp}
}
return io.ReadAll(resp.Body)
buf := &bytes.Buffer{}
_, err = io.Copy(buf, resp.Body)
return buf.Bytes(), err
}

func (cli *Client) downloadEncryptedMedia(url string, checksum []byte) (file, mac []byte, err error) {
Expand Down

0 comments on commit 24f5d3a

Please sign in to comment.