Browse Source

Should error out on JSON error.

master
Brett Bohnenkamper 6 years ago
parent
commit
5c5d8c73d9
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      Upload/upload.sh

+ 5
- 4
Upload/upload.sh View File

@@ -7,19 +7,20 @@ files="$@"

if [[ -z "${files}" ]]; then
printf 'You must submit a file to be uploaded!\n'
exit 0
exit 1
else
printf 'Uploading file(s) now!'
n=1
for i in "$@"; do
printf "\nUploading file #${n} ... "
out=$(curl -sf -F file="@${i}" http://api.teknik.io/upload/post)
if [[ -n "${out}" ]]; then
if [[ "${out}" =~ "error" ]]; then
printf 'error uploading file!\n'
exit 1
else
out="${out##*name\":\"}"
out="${out%%\"*}"
printf "uploaded! Your file can be found at http://u.teknik.io/${out}\n"
else
printf 'error uploading file!\n'
fi
((n++))
done

Loading…
Cancel
Save