Giter Site home page Giter Site logo

cloud-storage-webservice's Introduction

GitHub repo size GitHub last commit GitHub issues GitHub pull requests

Documentation

Introduction

this is a simple app that can be used to simulate how to use the storage service in GCP via Storage libraries by GCP. This app is built using NodeJS and ExpressJS. You can deploy this app to GCP App Engine and use it to test the storage service. The most important file is the StorageService.js. This file contains the code that can be used to interact with the storage service.

How to use

Before you use this app to simulate the storage service, you need to create a service account key and a bucket in GCP. You can follow the steps below to create the service account key and the bucket.

How to create a service account key? follow the steps below:

  • Go to the GCP console
  • Go to the IAM & Admin > Service Accounts page
  • Click on the create service account button
  • Fill the service account name
  • Fill the description
  • Give the role to the service account (Storage Admin - with desc: Full control of GCS resources) from the grant this service account access to the project
  • CLick continue button
  • Click done button
  • Click on the service account that you want to use
  • Click on the keys tab
  • Click on the add key button
  • Choose the JSON key type
  • Click on the create button
  • Save the key file (download it)

Now i assume that you already have the service account key file. You can follow the steps below to use use this app to simulate the storage service.

  1. Clone this repo
  2. Install the dependencies by running npm install
  3. Upload your service account key file to the root directory of this app (the key file is the file that you have downloaded in the previous step)
  4. Create a .env file and add the following variables
    • PORT = port number for the app (8080 by default)
    • GOOGLE_APPLICATION_CREDENTIALS = path to your service account key (file is .json)
    • BUCKET_NAME = name of your bucket
    • PROJECT_ID = your project id
  5. Run the app by running npm start to test the app is running.
  6. You can skip this step if you try to run the prev step in cloud shell. You can use postman to test the app by using the postman collection at testing section below. You can also use the app by using the url http://localhost:8080/ (8080 is the default port number)
  7. Deploy the app to GCP App Engine by running gcloud app deploy from cloud shell in the console or from your local machine if you have installed the gcloud sdk
  8. Test the app by using the url https://<your-app-id>.appspot.com/ (you can find the app id in the GCP console)

What features are available?

  1. Upload file

    Notes: You only can upload one file at a time. The file will be uploaded to the bucket that you have set in the .env file. The file will be uploaded to the root directory of the bucket. The file will be uploaded with the name that you have set in the form and prefixed by unix epoch time.

    the file uploaded must be in form data with the key file and the value is the file that you want to upload.

    this feature is using POST method and the url is /

  2. Download file

    Notes: You only can download one file at a time. The file will be downloaded from the bucket that you have set in the .env file.

    this feature is using GET method and the url is /download/{filename}

  3. Delete file

    Notes: You only can delete one file at a time. The file will be deleted from the bucket that you have set in the .env file.

    this feature is using DELETE method and the url is /delete/{filename}

  4. List files

    Notes: You can list all the files in the bucket that you have set in the .env file.

    this feature is using GET method and the url is /

Testing

You can run the postman by push the button below

Run in Postman

change the url from http://localhost:3000/ to your own url after you successfully deploy the app.

cloud-storage-webservice's People

Contributors

xharf avatar

Stargazers

Nahdhiyah 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.