Skip to content

Instantly share code, notes, and snippets.

@amithgc
Created August 4, 2022 14:38
Show Gist options
  • Save amithgc/1c4dbb43b07340a58e0c4d391d782440 to your computer and use it in GitHub Desktop.
Save amithgc/1c4dbb43b07340a58e0c4d391d782440 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Generate a Github Personal Access token and use it here
API_TOKEN="<YOUR GITHUB TOKEN>"
#Update the URL Below
GITHUB_URL="https://api.github.com/repos/<USER NAME>/<REPO NAME>"
# Getting the Base64 for your image
base64Data=$( base64 Capture.jpg )
#Getting the current timestamp to rename your uploading image
timestamp=$(date +%s)
#Uploading the Image
curl --location --request PUT $GITHUB_URL'/contents/images/'$timestamp'.jpg' \
--header 'Authorization: token '$API_TOKEN \
--header 'Content-Type: text/plain' \
--data-raw '{"message":"Image Pushed","committer":{"name":"Amith","email":"octocat@github.com"},"content":"'$base64Data'"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment