No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/main/java/com/acloudysky/storage
README.md
gcp-storage-client.gif
pom.xml

README.md

gcp-storage-client

Java console application showing how to interact with Google Cloud Storage.This is a simple command line client application that eliminates unnecessary clutter and shows the basic logic to interact with Google Cloud Storage. Hopefully this will help you to understand the syntax (and semantic) of the API. The following figure is the application architecture (class diagram):

Event Trace

The application interacts with the Google Cloud Storage via its REST API using the related Google Java client library. For more information, see Google API Client Libraries. See also Cloud Programming REST API. See related blog post at Build GCP Cloud Storage Client.

Prerequisites

You must have Maven installed. The dependencies are satisfied by building the Maven package. The application uses a custom client authentication app. The app is included as a JAR in the downloadable code. Please include this JAR in your project. For more information, see GCP Cloud Service Client Apps – Common Tasks. See also Build GCP Service Authentication.

Security Credentials

You need to set up your Google security credentials before the sample code is able to connect to the Google Storage service. You can do this by creating a file named "client_secrets.json" at ~/.store/storage_sample (C:\Users\USER_NAME.store\storage_sample\ for Windows users) and saving the following information in the file:

  1. Client ID
  2. Client secrets
  3. Other...

You obtain this information by downloading the JSON format of the client information for native application of your project at: Google Console. Then copy this information in the secretsFile such as client_secrets.json. Keep this file in a safe place.

Default Settings

The application assumes that a file exists that contains default settings. The file is assumed to be at ~/.store/storage_sample/sample_settings.json (C:\Users\USER_NAME.store\storage_sample\sample_settings.json for Windows users). The settigs are in Jason format similar to the following:

"project": "<your project ID>",
"defaultbucket": "<name of your default bucket>",
"defaultobject": "<name of your default object>",
"prefix": "<your prefix>", 
"email":<your e-mail>" 

Running the Example

The application connects to Google Cloud Storage, and allows the user to create a bucket, upload an object into the bucket, download the object, delete the object and delete the bucket. All you need to do is run it by following these steps:
  1. From the project, create an executable JAR

  2. From a terminal window, go to the directory containing the JAR and execute a command similar to the following:

     java -jar gcp-storage-client.jar	
    

License

This sample application is distributed under the

Apache License, Version 2.0