Skip to content

Instantly share code, notes, and snippets.

@baodinh
Created August 26, 2020 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baodinh/8b40831acfc05a2c9350677a4081d8bb to your computer and use it in GitHub Desktop.
Save baodinh/8b40831acfc05a2c9350677a4081d8bb to your computer and use it in GitHub Desktop.
Convert data:image/png;base64,iVBORw0KGgoAAA to []byte
func streamToByte(stream io.Reader) []byte {
buf := new(bytes.Buffer)
buf.ReadFrom(stream)
return buf.Bytes()
}
// pass reader to NewDecoder
dec := base64.NewDecoder(base64.StdEncoding, strings.NewReader(base64string[i+1:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment