You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pomf 626B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # ~/.local/bin/pomf <file [file [...]]>
  3. # Generate the form arguments for curl
  4. for f in "$@"; do
  5. if [[ -e "$f" ]]; then
  6. curl_args+=(-F "files[]=@$f")
  7. else
  8. printf >&2 '%s: File does not exist\n' "$f"
  9. fi
  10. done
  11. # Make sure we have something to upload
  12. if [[ -z "$curl_args" ]]; then
  13. printf >&2 'Nothing found to upload\n'
  14. exit 1
  15. fi
  16. upload=$(curl -#S "${curl_args[@]}" http://pomf.se/upload.php)
  17. geturls=$(jshon -e files -a -e name -upe url -u <<< "$upload")
  18. while {
  19. read -r name
  20. read -r url
  21. } do
  22. printf '%s: http://a.pomf.se/%s\n' "$name" "$url"
  23. done <<< "$geturls"