Datadog Gold Partner logo

Google Cloud Storage Editor

By Neil Kolban.Jun 27, 2022

Article Google Cloud Storage Editor 1

Google Cloud Storage (GCS) is a cloud based blob storage technology. It exposes an API that allows applications to store and retrieve data. Google provides a browser for GCS that allows us to view the files contained within. We can upload new files and download existing ones. What is not present in the Google GCS browser is the ability to view or edit the content of these files. To see what is in a file, one must first download the file and then open it in a local editor.

This article describes an open source project that allows us to select files in GCS and then open them in an editor all from within a browser based web app. The application is available for immediate examination by visiting:

https://kolban-google.github.io/gcs-editor/

To use the application, one must first create a Google Cloud project and build some OAuth credentials and a client id. The reason for this is that when GCS API calls are made, they must be attributed to some project for billing purposes.

Installation

Create a GCP project.

Configure the OAuth consent:

Open the Google Cloud App and visit APIs & Service and select OAuth consent screen:

Article Google Cloud Storage Editor 2

In the next panel, select “Internal”:

Article Google Cloud Storage Editor 3

Now we get to enter the details of your own environment. The values here are examples only:

Article Google Cloud Storage Editor 4

In the scopes, we define that we wish the application to be able to work with Cloud Storage:

Article Google Cloud Storage Editor 5

This is what the screen looks like after configuring scope:

Article Google Cloud Storage Editor 6

A summary page is shown at the end:

Article Google Cloud Storage Editor 7

Next, set up credentials

Article Google Cloud Storage Editor 8
Article Google Cloud Storage Editor 9
Article Google Cloud Storage Editor 10
Article Google Cloud Storage Editor 11

Make a note of your client id. Launch the GCS Editor application. From the menu at the top left of GCS Editor, click on Settings:

Article Google Cloud Storage Editor 12

Paste in the Client Id value that was generated in the previous step and click OK. This will allow the application to make GCS calls that will be attributed to the associated project.

Article Google Cloud Storage Editor 13

The Client Id will be remembered by the browser and need not be entered again.

Usage

With the GCS Editor configured, we now turn our attention to how it can be used.

Article Google Cloud Storage Editor 14

We perform three steps:

  1. We sign in to the app so that GCS knows who we are. When requests are then made to GCS, they are authorized based on this identity.

We click the “SIGN IN” button at the top.

Article Google Cloud Storage Editor 15

2. We select a bucket that we wish to load files from. We click the “SELECT BUCKET” button at the top. Here we enter the name of a GCS bucket.

Article Google Cloud Storage Editor 16

3. Load a file. We are now ready to load a file. We click the “LOAD” button. A file browser dialog is shown to us that is browsing the GCS files in the bucket. We can then select a file that we wish to open and click the “LOAD” button.

Article Google Cloud Storage Editor 17

and now we are looking at the content of the file:

Article Google Cloud Storage Editor 18

Should we wish, we can make changes in the editor and click the “SAVE” button. This will re-write the file back to GCS.

The GitHub Project

The source of this app is available on GitHub and submissions and issues are welcomed. This is an open source (as-is) project and should not be considered a Google offering in any form.

The core of the project is based upon:

  • REACT as the browser UI technology
  • Chonky for file selection in GCS
  • Ace as the editor for the files

It has been tested on Chrome.

A deployment of the application can be found on GitHub pages here:

https://kolban-google.github.io/gcs-editor/

However it can be installed in your own environment by cloning the project and running a build.

FAQ

No client ID supplied

If you see the following dialog it means that you haven’t specified a Client ID. See the installation section at the top of the article.

Article Google Cloud Storage Editor 19
Not signed in

If you see the following dialog, it means that you haven’t signed in.

Article Google Cloud Storage Editor 20
Credits
References

The original article published on Medium.

Related Posts