Skip to content

milexm/gcp-drive-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

gcp-drive-client

Java console application showing how to interact with Google Drive.This is a simple command line client application that eliminates unnecessary clutter and shows the basic logic to interact with Google Drive. 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 Drive 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 Drive 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-drive-client.jar	
    

License

This sample application is distributed under the

Apache License, Version 2.0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages