从客户端URL访问云存储 [英] Access to cloud storage from client URL

查看:173
本文介绍了从客户端URL访问云存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Google云应用程序中,我需要打开位于项目的云存储中的文件.我试图使用以下形式的URL来访问文件,但出现以下错误: http://storage.googleapis.com/my-bucket/my-file 错误:访问被拒绝.匿名呼叫者没有存储对象

From a Google cloud application, I need to open a file located in my project’s cloud storage. I tried to use a URL of the following form to access the file but I get the error below: http://storage.googleapis.com/my-bucket/my-file Error: Access denied. Anonymous caller does not have storage objects

www.googleapis.com/upload/storage/v1/b/ http://my_appl//my-bucket/我的文件 错误404 www.googleapis.com/storage/v1/b/my-bucket/my-file 错误404

www.googleapis.com/upload/storage/v1/b/http://my_appl//my-bucket/my-file Error 404 www.googleapis.com/storage/v1/b/my-bucket/my-file Error 404

https://www.googleapis.com /storage/v1/b/my-bucket/o/my-file 代码":401, "message":匿名呼叫者没有storage.objects.get访问my-bucket/my-file

https://www.googleapis.com/storage/v1/b/my-bucket/o/my-file "code": 401, "message": "Anonymous caller does not have storage.objects.get access to my-bucket/my-file

https ://www.googleapis.com/storage/v1/b/my-bucket/o/my-file/place?key = my-key 找不到

我输入的网址不正确吗?

Am I composing the URL incorrectly?

推荐答案

http://storage.googleapis.com/my-bucket/my-file 

这很好.但是,除非对象是公共可读的,否则您需要授权该请求,这意味着要么在请求中包括带有适当凭据的"Authorization"标头,要么使用服务帐户的私钥对URL进行签名.

This one is fine. However, unless an object is publicly readable, you'll need to authorize the request, which means either including an "Authorization" header in the request with appropriate credentials or signing the URL with the private key of a service account.

https://www.googleapis.com/download/storage/v1/b/my-bucket/o/my-file?key=my-key&alt=media

也可以,但是API密钥不提供身份验证.除非对象是公开可见的,否则您仍然需要一个Authorization标头.

This is also okay, but an API key does not provide authentication. You'll still need an Authorization header unless the object is publicly viewable.

这篇关于从客户端URL访问云存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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