summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-03-21 17:07:09 +0100
committerFlorian Pritz <bluewind@server-speed.net>2011-03-21 17:14:04 +0100
commit799ccd27de66c598b908c3bed9ded7aa932348f5 (patch)
treeed8d04e0be28a4a60163f42dc20deb72126eb211
parent569475514daf40fc44fa24a3bdf2f31da848a71a (diff)
fall back to curl if fb-upload is unavailable
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
-rw-r--r--fb.in24
1 files changed, 21 insertions, 3 deletions
diff --git a/fb.in b/fb.in
index ce85695..b63ac28 100644
--- a/fb.in
+++ b/fb.in
@@ -63,9 +63,27 @@ do_upload() {
return 1
fi
fi
- if ! $LIBDIR/fb-upload "$PASTEBIN/file/do_upload" "$file" > $TMPFILE; then
- EXITCODE=1
- return 1
+
+ # fb-upload handles corner cases (comma in the filename) better
+ if [ -x "$LIBDIR/fb-upload" ]; then
+ if ! $LIBDIR/fb-upload "$PASTEBIN/file/do_upload" "$file" > $TMPFILE; then
+ EXITCODE=1
+ return 1
+ fi
+ else
+ CURLOPTS="-# -n -L -A $USERAGENT $EXTRA"
+ if [ `stat -c %s -- "$file"` -eq "0" ] || echo "$file" | grep -F -q ","; then
+ basefilename=`echo "$basefilename" | tr -d ,`
+ if ! curl $CURLOPTS -F "file=@-;filename=$basefilename" "$PASTEBIN/file/do_upload" < "$file" > $TMPFILE; then
+ EXITCODE=1
+ return 1
+ fi
+ else
+ if ! curl $CURLOPTS -F "file=@$file" "$PASTEBIN/file/do_upload" > $TMPFILE; then
+ EXITCODE=1
+ return 1
+ fi
+ fi
fi
sed '$d' $TMPFILE >&2
URL=`tail -1 $TMPFILE`"$EXTENSION"