Arcade Re-Trail: Vaults & Vectors | Cloud Storage: Qwik Start - CLI/SDK

Solution for Arcade Re-Trail: Vaults & Vectors | Cloud Storage: Qwik Start - CLI/SDK. 1 lab: GSP074. Fast copy-paste commands for Google Cloud.

GSP074 — Cloud Storage: Qwik Start - CLI/SDK

Estimated time: 15 minutes

# 🚀 Cloud Storage: Qwik Start - CLI/SDK > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide is designed to help learners understand Cloud Storage, command-line operations, object management, folder organization, and Access Control Lists (ACLs) through hands-on practice. Always attempt the lab yourself first and follow Google Cloud Skills Boost / Qwiklabs Terms of Serv

# ==============================================================================
# ORBIT OF OPS - GSP074 (COMMAND 1 OF 1)
# ==============================================================================
GREEN='\e[1;32m'
CYAN='\e[1;36m'
YELLOW='\e[1;33m'
MAGENTA='\e[1;35m'
RESET='\e[0m'
BOLD='\e[1m'

clear
echo -e "${CYAN}${BOLD}"
cat << "EOF"
  ____       _     _ _            __    ___            
 / __ \     | |   (_) |          / _|  / _ \           
| |  | |_ __| |__  _| |_   ___  | |_  | | | |_ __  ___ 
| |  | | '__| '_ \| | __| / _ \ |  _| | | | | '_ \/ __|
| |__| | |  | |_) | | |_ | (_) || |   | |_| | |_) \__ \
 \____/|_|  |_.__/|_|\__| \___/ |_|    \___/| .__/|___/
                                            | |        
                                            |_|        
EOF
echo -e "${RESET}"
echo -e "${MAGENTA}${BOLD}>>> ORBIT OF OPS: GSP074 INITIATED <<<${RESET}\n"

export PROJECT_ID=$(gcloud config get-value project 2>/dev/null)
export BUCKET_NAME="gs://${PROJECT_ID}"

export REGION=$(gcloud compute project-info describe \
--format="value(commonInstanceMetadata.items[google-compute-default-region])" 2>/dev/null | tail -n 1)

if [[ -z "$REGION" ]]; then
    read -p "$(echo -e "${BOLD}${CYAN}Please enter the lab Region (e.g., us-central1): ${RESET}") " REGION
    export REGION
fi

echo -e "${YELLOW}${BOLD}[Orbit of Ops] Setting compute region...${RESET}"
gcloud config set compute/region $REGION --quiet

echo -e "${YELLOW}${BOLD}[Orbit of Ops] Task 1: Creating Cloud Storage bucket...${RESET}"
gcloud storage buckets create $BUCKET_NAME --quiet

echo -e "${CYAN}${BOLD}[Orbit of Ops] Task 2: Downloading and uploading image to bucket...${RESET}"
curl -s https://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Ada_Lovelace_portrait.jpg/800px-Ada_Lovelace_portrait.jpg --output ada.jpg
gcloud storage cp ada.jpg $BUCKET_NAME --quiet
rm ada.jpg

echo -e "${MAGENTA}${BOLD}[Orbit of Ops] Task 3: Downloading image from bucket...${RESET}"
gcloud storage cp -r $BUCKET_NAME/ada.jpg . --quiet

echo -e "${YELLOW}${BOLD}[Orbit of Ops] Task 4: Copying object to a folder in the bucket...${RESET}"
gcloud storage cp $BUCKET_NAME/ada.jpg $BUCKET_NAME/image-folder/ --quiet

echo -e "${CYAN}${BOLD}[Orbit of Ops] Tasks 5 & 6: Listing bucket contents and details...${RESET}"
gcloud storage ls $BUCKET_NAME
gcloud storage ls -l $BUCKET_NAME/ada.jpg

echo -e "${MAGENTA}${BOLD}[Orbit of Ops] Task 7: Making object publicly accessible...${RESET}"
gcloud storage objects update $BUCKET_NAME/ada.jpg --add-acl-grant=entity=allUsers,role=READER --quiet

echo -e "\n${GREEN}${BOLD}🎉 COMMAND 1 COMPLETE!${RESET}"
echo -e "${CYAN}${BOLD}You can now safely click 'Check my progress' on all tasks in your lab manual.${RESET}"