Access to cloud storage from client URL

2019-08-26 06:52发布

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/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 "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 Not found

Am I composing the URL incorrectly?

1条回答
再贱就再见
2楼-- · 2019-08-26 07:20
http://storage.googleapis.com/my-bucket/my-file 

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

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.

查看更多
登录 后发表回答