Having trouble converting an image.Image to []byte. The problem spot is wrapped in dotted lines.
image_data, err := mybucket.Get(key)
if err != nil {
panic
Adding on to Stephen's code, if you're using the aws s3 go SDK to put an object, your code would look like:
// create buffer
buff := new(bytes.Buffer)
// encode image to buffer
err = png.Encode(buff, new_image)
if err != nil {
fmt.Println("failed to create buffer", err)
}
// convert buffer to reader
reader := bytes.NewReader(buf.Bytes())
// use it in `PutObjectInput`
putInput := s3.PutObjectInput{
Bucket: aws.String("my_bucket"),
Body: reader,
}
// send response
resp, err := svc.PutObject(&putInput)