-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpomf.sh
75 lines (57 loc) · 1.25 KB
/
pomf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# pomf.se uploader v.0.001
# Alternatives:
#upload_url='https://pomf.cat/upload.php'
#return_url='https://a.pomf.cat'
#upload_url='https://mixtape.moe/upload.php'
#return_url='https://my.mixtape.moe'
info_help() {
cat <<-_EOF
single file:
./pomf.sh file.txt
many files:
./pomf.sh file1 file2
./pomf.sh *.txt
all files:
./pomf.sh *.*
_EOF
exit
}
usage()
{
echo " $0 -help "
exit 1
}
[ -n "$1" ] || { echo 'No filename given!'; usage; }
#
for FILES in "$@"
do
#
if [ ! -e "$1" ]
then
case $1 in
h|help|-h|--h|-help|--help)
info_help
esac
fi
FRS=`echo $FILES | sed 's/[ (),]/_/g'`
mv -v "$FILES" "$FRS"
[ -f "$FRS" ] || { echo 'File does not exist!'; usage; }
upload_url='https://pomf.space/upload.php'
return_url='https://a.pomf.space'
json_out="$(curl -# --form files[]=@"$FRS" $upload_url)"
remote_filename="$(echo $json_out | jq -r '.files[0].url')"
success=$(echo $json_out | jq -r '.success')
if [[ $success = true ]]
then
file_url="$return_url/$(basename $remote_filename)"
echo `date +%d.%m.%Y\ %H:%M:%S | tr -d '\012'; echo -n ' ' `
echo "SHA Checksum $(shasum "$FRS")"
echo "$file_url"
else
echo 'File upload unsuccessful!'
exit 1
fi
#
done
#