Created
April 8, 2017 14:49
-
-
Save caiosba/de3a431e39f27adfc2a01e58a390262d to your computer and use it in GitHub Desktop.
Upload an image to Imgur - no API keys needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: ./upload-img-to-imgur.sh <image file path> | |
# Output: URL to the image on Imgur | |
filepath=$1 | |
content_type="image/png" | |
filename="$(basename filepath)" | |
curl -X POST "http://imgur.com/upload" \ | |
-H "Referer: http://imgur.com/upload" \ | |
-F "Filedata=@$filepath;filename=$filename;type=$content_type" 2>/dev/null | sed 's/^{"data":{"hashes":\["\([^"]\+\).*/http:\/\/imgur.com\/\1/g' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment