diff options
author | Florian Pritz <bluewind@server-speed.net> | 2011-03-21 17:07:09 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@server-speed.net> | 2011-03-21 17:14:04 +0100 |
commit | 799ccd27de66c598b908c3bed9ded7aa932348f5 (patch) | |
tree | ed8d04e0be28a4a60163f42dc20deb72126eb211 /fb.in | |
parent | 569475514daf40fc44fa24a3bdf2f31da848a71a (diff) |
fall back to curl if fb-upload is unavailable
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'fb.in')
-rw-r--r-- | fb.in | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -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" |