Google Cloud Storage JSON REST API-获取保存在子目录中的对象 [英] Google Cloud Storage JSON REST API - Get object held in a sub-directory

查看:80
本文介绍了Google Cloud Storage JSON REST API-获取保存在子目录中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要访问我存储在Google Cloud Storage中的对象-如果根据文档使用以下调用将该对象存储在存储桶的最高级别,这将非常简单:

I'm looking to access an object I have stored in Google Cloud Storage - this is straightforward enough if the object is stored at the highest level of the bucket using the following call as per the documentation:

https://storage.googleapis.com/storage/v1/b/bucketname/o/objectname?alt = media

但是,如果文件保存在存储桶的子目录中,则无法访问它.在此文档中似乎没有任何指导.我尝试了以下电话,但均未成功:

However, if the file is held within a sub-directory on the bucket I'm unable to access it. There doesn't seem to be any guidance in the docs on this. I've tried the following calls but neither have been successful:

https://storage.googleapis.com/storage/v1/b/bucketname/o/foldername/objectname?alt = media https://storage.googleapis.com/storage/v1/b/bucketname/foldername/o/objectname?alt = media

我不知道该目录是否应该作为主URL的一部分或作为查询参数或其他地方提交.请注意,我也已经通过标头提交了访问令牌.

I don't know if the directory is supposed to be submitted as part of the main URL or as a query parameter or somewhere else. Please note that I've submitted the Access Token through the header, too.

我还希望能够在子目录中存储和列出对象,因此对此的任何帮助也将不胜感激.

I'd also like to be able to store and list objects within a sub-directory so any help with that would be greatly appreciated too.

有人可以请教吗?

推荐答案

您需要使用对象名称对/进行URL编码:

You need to URL encode the / in the object name:

https://cloud.google.com/storage/docs/request-endpoints#encoding

因此应该是(假设没有其他/):

therefore it should be (assuming no other /):

https://storage.googleapis.com/storage/v1/b/bucketname/o/foldername%2Fobjectname?alt = media

这篇关于Google Cloud Storage JSON REST API-获取保存在子目录中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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