将Google Cloud Vision API授权给Google Storage映像 [英] Authorize Google Cloud Vision API to Google Storage image

查看:87
本文介绍了将Google Cloud Vision API授权给Google Storage映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Node上使用Google Cloud Vision API分析存储在Google Storage中的图像.我已经成功地对base64进行了图像编码并上传了图像,但想通过对我在Google Storage中拥有的文件执行以加快处理速度.我的要求是这样,

From Node, I am attempting to use Google Cloud Vision API to analyze an image stored in Google Storage. I have successfully base64 encoded an image and uploaded it but would like to speed up the process by executing against files I have in Google Storage. My Request is so,

{"requests":[{"image":{"source":{"gcsImageUri":"gs://mybucket/10001.jpg"}},"features":[{"type":"LABEL_DETECTION ," maxResults:10}]}]}

{ "requests":[ { "image":{ "source": { "gcsImageUri" : "gs://mybucket/10001.jpg" } }, "features":[ { "type":"LABEL_DETECTION", "maxResults":10 } ] } ] }

但是我从通话中收到此错误,

but I receive this error from my call,

{"responses":[{"error":{"code":7,"message":图像注释者::用户权限不足.:ACCESS_DENIED:匿名呼叫者没有storage.objects.get访问权限对象mybucket/10001.jpg." }}]}

{ "responses": [ { "error": { "code": 7, "message": "image-annotator::User lacks permission.: ACCESS_DENIED: Anonymous callers do not have storage.objects.get access to object mybucket/10001.jpg." } } ] }

我没有为此请求使用任何google SDK或node_modules,只是使用了浏览器API密钥和http模块.我必须在Cloud Storage中设置一些权限以允许Vision API访问存储桶中的对象吗?如果是这样,那我是Google Cloud Platform的新手,但是在AWS IAM角色方面拥有丰富的经验.

I am not using any google SDK or node_modules for this request, just a Browser API Key and the http module. Is there some permissions I have to set within Cloud Storage to allow Vision API access to the objects in the bucket? If so what would that be, I am new to Google Cloud Platform but have extensive experience with AWS IAM roles.

谢谢, VIPER

推荐答案

您可能正在使用不可公开读取的GCS图像匿名调用Cloud Vision API.您可能提供了API密钥,但是API密钥不对请求进行身份验证.您可以通过以下两种方法之一解决此问题:

You are probably invoking the Cloud Vision API anonymously with a GCS image that is not publicly readable. You are likely providing an API key, but API keys do not authenticate request. You can fix this problem in one of two ways:

  1. 向Cloud Vision API发出经过身份验证的请求,以具有读取GCS文件授权的特定用户身份进行身份验证,或者

  1. Make an authenticated request to the Cloud Vision API, authenticating as a particular user that has authorization to read the GCS file, or

设置GCS文件以允许匿名读取访问.您可以从控制台通过选择对象的公共可读"复选框或使用如下命令行客户端来执行此操作:gsutil acl ch -g AllUsers:R gs://mybucket/10001.jpg.

Set the GCS file to allow anonymous read access. You can do this from the console by checking the "publicly readable" checkbox by the object or by using the command-line client like this: gsutil acl ch -g AllUsers:R gs://mybucket/10001.jpg.

这篇关于将Google Cloud Vision API授权给Google Storage映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆