A bash-based CLI tool that allows users to quickly upload files to Google Cloud Storage, providing a seamless upload experience similar to popular storage services.
- Google Cloud Account: You must have a Google Cloud account with active billing. For more information, see Create free account.
- Required Permissions: To create and manage Cloud Storage resources, you need the Storage Admin (roles/storage.admin) IAM role for the project. During installation, sign in to the gcloud CLI with:
- User credentials, or
- A service account. For more information, see Setup & Authentication: (Optional) Service Account.
- Bash Environment: Available on Linux/Unix, macOS, and Windows Subsystem for Linux.
clouduploader OBJECT [--bucket=BUCKET] [--storage-class=STORAGE_CLASS]
Note: Only the files
setup
andclouduploader
is required to perform simple upload to Google Cloud Storage
Using Git:
git clone https://github.com/yunchengwong/clouduploader-cli.git
cd clouduploader-cli
or
(Recommended) Using GitHub Codespaces (folder .devcontainer
required):
chmod 755 setup clouduploader
./setup
To run the program clouduploader
without the ./
prefix, you need to add its path to your system's PATH
variable.
Temporary Solution:
Run the following command in your shell terminal:
PATH=$PATH:$(pwd)
Note: This change is temporary and will reset when you close the terminal.
Permanent Solution:
-
Copy clouduploader directory, ex.
/workspaces/username/clouduploader-cli/src
-
Open your shell configuration file (
~/.bashrc
,~/.zshrc
, etc.). -
Add the following line:
export PATH=$PATH:<CLOUDUPLOADER_DIR>
- Save the file and reload the shell configuration:
source ~/.bashrc # or source ~/.zshrc
Note: Editing the shell configuration file directly modifies your environment settings permanently. Ensure you have the necessary permissions and understand the changes being made.
https://learntocloud.guide/phase1/
https://github.com/microsoft/bash-for-beginners
https://cloud.google.com/sdk/docs/install-sdk#installing_the_latest_version
# 1. Before you install the gcloud CLI, make sure that your operating system meets the following requirements:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl
# 2. Import the Google Cloud public key.
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
# 3. Add the gcloud CLI distribution URI as a package source.
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# 4. Update and install the gcloud CLI:
sudo apt-get update && sudo apt-get install google-cloud-cli
# 5. Run gcloud init to get started:
gcloud init
https://www.cloudskillsboost.google/course_templates/49/labs/386466
- create service account
clouduploader-storage-admin
with Storage Admin role - create and download a JSON key file in
clouduploader-storage-admin
> KEYS, rename it tocredentials.json
- upload
credentials.json
toclouduploader-cli
- run the following command to reconfigure google cloud cli
gcloud
:
gcloud auth activate-service-account --key-file credentials.json
https://cloud.google.com/storage/docs/discover-object-storage-gcloud https://cloud.google.com/sdk/gcloud/reference/storage
# Create a bucket
gcloud storage buckets create gs://my-awesome-bucket/ --uniform-bucket-level-access
gcloud storage buckets create gs://my-bucket --default-storage-class=nearline --location=asia
# Upload an object into your bucket
gcloud storage cp *.txt gs://my-awesome-bucket
gcloud storage cp --recursive dir gs://my-awesome-bucket
# List contents of a bucket or folder
gcloud storage ls
gcloud storage ls gs://my-awesome-bucket
gcloud storage ls --recursive gs://my-awesome-bucket
https://cloud.google.com/storage/docs/access-control/making-data-public https://cloud.google.com/storage/docs/uniform-bucket-level-access
gcloud storage objects update gs://BUCKET_NAME/OBJECT_NAME --add-acl-grant=entity=AllUsers,role=READER
https://cloud.google.com/storage/docs/encryption
Cloud Storage always encrypts your data on the server side, before it is written to disk, at no additional charge.