Created
March 26, 2010 21:29
-
-
Save 2bj/345415 to your computer and use it in GitHub Desktop.
bash implementation of files.namba.kg
This file contains 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
#!/usr/bin/env bash | |
# bash implementation of files.namba.kg | |
# @author 2bj (gml2bj gmail) | |
# @dependens curl, zenity | |
# TODO: | |
# * drag-n-drop (сейчас работает; надо создать лаунчер и дропнуть туда файло) | |
# * progress-bar | |
# * bulk upload (folder) | |
app_name=`basename $0` | |
#human_url="http://download.files.namba.kg/files/" | |
function show_usage(){ | |
cat << BLA | |
Usage: $app_name <file> ["description"] | |
maxfilesize - 50MB | |
BLA | |
} | |
if [ -z $1 ]; then | |
show_usage | |
exit | |
fi | |
if [ "$((50*1048576*10000/10000))" -lt `stat -c %s $1` ]; then | |
echo "error: File is too big; maxfilesize - 50MB" | |
exit | |
fi | |
url=$(curl http://files.namba.kg/anonymupload.php \ | |
-A "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9b5) Gecko/2008032619 Firefox/3.0b5" \ | |
-F "file=@$1" \ | |
-F "yes=1" \ | |
-F "description=$2" \ | |
-s -L -o /dev/null -w '%{url_effective}') | |
zenity --entry \ | |
--title="files.namba.kg" \ | |
--text="Upload complete" \ | |
--entry-text=$url | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment