Skip to content

Instantly share code, notes, and snippets.

Created November 27, 2018 10:05
What would you like to do?
Embedding or sharing an image or photo uploaded to Google Drive.
# Usage: googleImage
# Output:*/1ohKYjS7FxgkHCqdhP5gpYPMJN8xueqF2
function googleImage {
# Replace the parts around sharable link of google drive to extract the fileId
local fileId=$(echo '' | sed 's/https:\/\/\/file\/d\///g' | sed 's/\/view\?usp=sharing//g')
# Prepend the exportable link
local url="$fileId"
# Get public generated url
local publicUrl=$(curl -Ls -o /dev/null -w %{url_effective} $url)
echo $publicUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment