I'm following this documentation to upload files to GCS. Setting Up Authentication for Server to Server Production Applications
It works in local but in production i get this error:
Post https://www.googleapis.com/upload/storage/v1/b/[bucket-name]/o?alt=json&prettyPrint=false&projection=full&uploadType=multipart: x509: failed to load system roots and no roots provided.
func UploadIMG(ctx *context.Context, file []byte, fileName string) error {
storageClient, err := storage.NewClient(*ctx)
if err != nil {
log.Fatal(err)
}
w := storageClient.Bucket(bucketName).Object(fileName).NewWriter(*ctx)
if _, err := w.Write(file); err != nil {return err}
if err := w.Close(); err != nil {return err}
oauthClient, err := google.DefaultClient(*ctx, cloudkms.CloudPlatformScope)
if err != nil {
log.Fatal(err)
}
kmsService, err := cloudkms.New(oauthClient)
if err != nil {
log.Fatal(err)
}
_ = kmsService
return nil
}