如何使用GoAPI客户端以编程方式创建Google云函数
有一个Go包用于与云函数API交互,但我不知道如何使用它来创建新函数。我在尝试上传到云存储桶的签名URL时遇到404和403错误如何使用GoAPI客户端以编程方式创建Google云函数,go,google-cloud-platform,google-cloud-functions,Go,Google Cloud Platform,Google Cloud Functions,有一个Go包用于与云函数API交互,但我不知道如何使用它来创建新函数。我在尝试上传到云存储桶的签名URL时遇到404和403错误 有人知道如何使用这个包部署云功能吗?我在使用google.golang.org/api/cloudfunctions/v1时遇到了类似的问题, 我遇到的403错误的第一个问题是由于使用了auth client 使用预签名生成上载URL,使用裸http客户端帮助 httpClient := http.DefaultClient data, err := ioutil.R
有人知道如何使用这个包部署云功能吗?我在使用google.golang.org/api/cloudfunctions/v1时遇到了类似的问题, 我遇到的403错误的第一个问题是由于使用了auth client 使用预签名生成上载URL,使用裸http客户端帮助
httpClient := http.DefaultClient
data, err := ioutil.ReadAll(reader)
if err != nil {
return err
}
request, err := http.NewRequest("PUT", uploadURL, bytes.NewReader(data))
if err != nil {
return err
}
request.Header.Set("content-type", "application/zip")
request.Header.Set("x-goog-content-length-range", "0,104857600")
request.Header.Set("Content-Length", fmt.Sprintf("%d", len(data)))
response, err := httpClient.Do(request)
if err != nil {
return err
}
我在404中看到的另一个问题是,我使用位置作为区域,而不是下面代码段中提供的完全限定名
var location = 'projects/${projectID}/locations/${region}'
projectService := cloudfunctions.NewProjectsLocationsFunctionsService(ctxClient.service)
createCall := projectService.Create(location, request.CloudFunction)
createCall.Context(ctxClient.Context())
return createCall.Do()
h
您还可以检查golang cloud functions google.golang.org/api/cloudfunctions/v1 api在本项目中的使用情况:
我在使用google.golang.org/api/cloudfunctions/v1时遇到了类似的问题, 我遇到的403错误的第一个问题是由于使用了auth client 使用预签名生成上载URL,使用裸http客户端帮助
httpClient := http.DefaultClient
data, err := ioutil.ReadAll(reader)
if err != nil {
return err
}
request, err := http.NewRequest("PUT", uploadURL, bytes.NewReader(data))
if err != nil {
return err
}
request.Header.Set("content-type", "application/zip")
request.Header.Set("x-goog-content-length-range", "0,104857600")
request.Header.Set("Content-Length", fmt.Sprintf("%d", len(data)))
response, err := httpClient.Do(request)
if err != nil {
return err
}
我在404中看到的另一个问题是,我使用位置作为区域,而不是下面代码段中提供的完全限定名
var location = 'projects/${projectID}/locations/${region}'
projectService := cloudfunctions.NewProjectsLocationsFunctionsService(ctxClient.service)
createCall := projectService.Create(location, request.CloudFunction)
createCall.Context(ctxClient.Context())
return createCall.Do()
h
您还可以检查golang cloud functions google.golang.org/api/cloudfunctions/v1 api在本项目中的使用情况:
请提供您已经尝试过的代码和解决方案。我只能复制和粘贴您一般问题的文档。请提供代码和您已经尝试过的解决方案。我只能复制和粘贴您一般问题的文档。