forked from amar-laksh/KDE-DolphinServiceMenu-IPFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsm-ipfs
executable file
·34 lines (23 loc) · 952 Bytes
/
dsm-ipfs
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
#!/usr/bin/env bash
SCRIPTNAME=$(basename "$0")
DATA_FILE="/tmp/$SCRIPTNAME"
if [ "$#" -ne 1 ]; then
kdialog --title IPFS --error "only one file can be uploaded" &>/dev/null
exit 1
fi
name=$(echo $1)
dbusRef=`kdialog --title IPFS --progressbar "Uploading..." 0`
qdbus $dbusRef showCancelButton false
res=$(curl --silent -X POST -H "Content-Type: multipart/form-data" -F "name=keyphrase" -F "name=user" -H "Content-Type: image/jpeg" -F "file=@$1" https://api.globalupload.io/transport/add)
uri=$(echo $res | cut -d "," -f2 | cut -d "\"" -f4)
size=$(echo $res | cut -d "," -f3 | cut -d "\"" -f4)
url=$(echo "https://gateway.ipfs.io/ipfs/$uri")
qdbus $dbusRef close
{
printf "%-17s %s\n" "name:" "$name"
printf "%-17s %s\n" "size:" "$size"
printf "%-17s %s\n" "url:" "$url"
printf "\n\nThe URL is copied to your clipboard!"
} > "$DATA_FILE"
echo $url | xclip -selection clipboard
kdialog --title IPFS --textbox "$DATA_FILE" &>/dev/null