1#!/bin/bash
2# Running this script requires "gcert" login.
3#
4# This script is used to fetch data from blob store based on the blob key.
5# For example, `bash fetch_blob_key.sh abcdefg output.profile`
6BLOB_KEY=$1
7OUTPUT=$2
8
9blob_id=$(echo "$BLOB_KEY"  | base64 --decode | gqui from rawproto:- proto blobstore.BlobRef | grep "BlobID :" | awk -F' ' '{print $3}')
10blob_id=$(echo "$blob_id" | sed -e 's/^"//' -e 's/"$//')
11/google/bin/releases/blobstore2/tools/bs2/bs2 read "$blob_id" > "$OUTPUT"
12