Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File listing from google cloud storage

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()) {

      }

and it is stated to use an AppIdentityCredential.

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.

like image 260
alperkin Avatar asked Feb 14 '13 01:02

alperkin


1 Answers

This should help you.

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)

like image 53
Eich Avatar answered Sep 23 '22 11:09

Eich