google-cloud-functions-go
google-cloud-functions-go copied to clipboard
interface conversion: http.http2StreamError is not http.http2writeFramer: missing method writeFrame
Getting this error when trying to use event bucket and then read the contents from Cloud Storage.
panic: interface conversion: http.http2StreamError is not http.http2writeFramer: missing method writeFrame
goroutine 1 [running]:
plugin.lastmoduleinit(0xcce400, 0xc42000e038, 0xccf470, 0x4c, 0xb8fde0)
/usr/local/go/src/runtime/plugin.go:60 +0x5e6
plugin.open(0x7ffc13527e00, 0xc, 0x0, 0x0, 0x0)
/usr/local/go/src/plugin/plugin_dlopen.go:72 +0x25d
plugin.Open(0x7ffc13527e00, 0xc, 0xb, 0x8154e8, 0xc)
/usr/local/go/src/plugin/plugin.go:30 +0x35
main.main()
This panic occurs when I instantiate a new client from cloud storage
ctx := context.Background()
client, err := storage.NewClient(ctx)
Here's the full code
package main
import (
"context"
"fmt"
"io/ioutil"
"log"
"cloud.google.com/go/storage"
"github.com/kelseyhightower/google-cloud-functions-go/event"
)
func F(e event.ObjectChange) (string, error) {
log.SetFlags(0)
log.Printf("processing object: %s", e.Data.Id)
log.Printf("bucket: %s", e.Data.Bucket)
log.Printf("filename: %s", e.Data.Name)
log.Printf("resource state: %s", e.Data.ResourceState)
ctx := context.Background()
client, err := storage.NewClient(ctx)
if err != nil {
log.Fatal(err)
}
rc, err := client.Bucket(e.Data.Bucket).Object(e.Data.Name).NewReader(ctx)
if err != nil {
log.Fatal(err)
}
contents, err := ioutil.ReadAll(rc)
rc.Close()
if err != nil {
log.Fatal(err)
}
log.Printf("file contents:", contents)
return "", nil
}