Coder Social home page Coder Social logo

gcp-storage-client's Introduction

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

gcp-storage-client's People

Contributors

milexm avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.