-
Notifications
You must be signed in to change notification settings - Fork 467
/
Introduction to APIs in Google
32 lines (26 loc) · 1.09 KB
/
Introduction to APIs in Google
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
gcloud services enable fitness.googleapis.com
gcloud services enable storage-api.googleapis.com
cat > values.json << EOF
{ "name": "$DEVSHELL_PROJECT_ID",
"location": "us",
"storageClass": "multi_regional"
}
EOF
---------------------------------------------------------
Now follow my instructions
----------------------------------------------------------
export OAUTH2_TOKEN=
-----------------------------------------------------------
export PROJECT_ID=$(gcloud config get-value project)
curl -X POST --data-binary @values.json \
-H "Authorization: Bearer $OAUTH2_TOKEN" \
-H "Content-Type: application/json" \
"https://www.googleapis.com/storage/v1/b?project=$PROJECT_ID"
curl -O demo-image.png https://cdn.qwiklabs.com/E4%2BSx10I0HBeOFPB15BFPzf9%2F%2FOK%2Btf7S0Mbn6aQ8fw%3D
output=$(realpath demo-image.png)
export OBJECT=$output
export BUCKET_NAME=$DEVSHELL_PROJECT_ID
curl -X POST --data-binary @$OBJECT \
-H "Authorization: Bearer $OAUTH2_TOKEN" \
-H "Content-Type: image/png" \
"https://www.googleapis.com/upload/storage/v1/b/$BUCKET_NAME/o?uploadType=media&name=demo-image"