谷歌云存储中的文件列表 [英] File listing from google cloud storage

查看:73
本文介绍了谷歌云存储中的文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我正在做的项目,我会将文件存储在Google的Cloud Storage中,并正在构建一个Web应用程序以与这些文件进行交互.我希望我的应用程序显示存储在存储桶中的文件列表(或对象可能是适当的名称).我是Web开发和Google API的新手.

For a project I'm doing, I will have files stored in Google's Cloud Storage and am building a web app to interface to those files. I would like my app to show a list of the files (or objects may be the appropriate name) stored in my bucket. I'm completely new to web development and google apis.

我一直在研究如何做到这一点,并发现了这段代码...

I've been researching how to do this and have found this bit of code...

Storage storage = new Storage(httpTransport, jsonFactory, credential);
    ObjectsList list = storage.objects().list("bucket-name").execute();
    for (Object obj : list.getItems()) {

      }

并声明使用AppIdentityCredential.

and it is stated to use an AppIdentityCredential.

任何有关如何将以上代码与AppIdentityCredential一起使用的建议,或有关使用Java列出存储在存储桶中的文件的任何建议,将不胜感激.

Any advice on how to use the above code along with an AppIdentityCredential or any advice on listing files stored in a bucket using java would be greatly appreciated.

推荐答案

This should help you.

请记住,您需要Cloud Storage API而不是GAE API(仅FYI :).您可以在此处了解有关该API的信息-> https://developers.google.com/storage/docs/json_api/v1/json-api-java-samples (JSON,也有XML API)

Please remember that you need the Cloud Storage API and not the GAE API (just FYI :) . You can read about that API here -> https://developers.google.com/storage/docs/json_api/v1/json-api-java-samples (JSON, there is also a XML API)

这篇关于谷歌云存储中的文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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