12345678910111213141516171819202122232425262728 |
- #!/bin/bash
- # ~/.local/bin/pomf <file [file [...]]>
-
- # Generate the form arguments for curl
- for f in "$@"; do
- if [[ -e "$f" ]]; then
- curl_args+=(-F "files[]=@$f")
- else
- printf >&2 '%s: File does not exist\n' "$f"
- fi
- done
-
- # Make sure we have something to upload
- if [[ -z "$curl_args" ]]; then
- printf >&2 'Nothing found to upload\n'
- exit 1
- fi
-
- upload=$(curl -#S "${curl_args[@]}" http://pomf.se/upload.php)
- geturls=$(jshon -e files -a -e name -upe url -u <<< "$upload")
-
- while {
- read -r name
- read -r url
- } do
- printf '%s: http://a.pomf.se/%s\n' "$name" "$url"
- done <<< "$geturls"
|