diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-07-26 17:21:29 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-07-26 17:21:29 +0200 |
commit | 3e032c563ff857c49e141ef88694e2423cfa5ee3 (patch) | |
tree | 527b7520278a24b8aee699f1e7e5b693f909e9d6 /fb | |
parent | 2633cc8bc1528d2c389c5daaa28b32847dea7e9d (diff) | |
download | bin-3e032c563ff857c49e141ef88694e2423cfa5ee3.tar.gz bin-3e032c563ff857c49e141ef88694e2423cfa5ee3.tar.xz |
fb: support filesize checking
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'fb')
-rwxr-xr-x | fb | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -11,12 +11,13 @@ # Optional: xclip #---------------------------------------------------- -VERSION="0.6.4" +VERSION="0.6.5" DELETE= EXTENSION="" GET= PASTEBIN="http://paste.xinu.at" +WARNSIZE=10485760 USERAGENT="fb-client/$VERSION" CLIPBOARD="" @@ -26,6 +27,13 @@ do_upload() { EXTRA="-F extension=$EXTENSION" fi TMPFILE=`mktemp "$TMPDIR/data.XXXXXX"` + if [ `stat -c %s "$1"` -gt "$WARNSIZE" ]; then + WARNSIZE=`curl -s "$PASTEBIN/file/get_max_size"` + if [ `stat -c %s "$1"` -gt "$WARNSIZE" ]; then + echo "Warning: Your upload is too big and would be rejected. Maximum size is: $WARNSIZE bytes. Skipping..." >&2 + return + fi + fi curl -# -n -L -A $USERAGENT $EXTRA -F "file=@$1" "$PASTEBIN/file/do_upload" > $TMPFILE sed '$d' $TMPFILE >&2 URL=`tail -1 $TMPFILE` |