Skip to content

Instantly share code, notes, and snippets.

@dmnc-net
Last active June 4, 2021 10:33
Show Gist options
  • Save dmnc-net/5a4e64ac1c21accb377dc8e9f21206ac to your computer and use it in GitHub Desktop.
Save dmnc-net/5a4e64ac1c21accb377dc8e9f21206ac to your computer and use it in GitHub Desktop.
webshare.cz - cURL based file upload
#!/bin/bash
: '
webshare.cz single upload with cURL by dmnc_net
requirements:
cURL
jq - https://stedolan.github.io/jq/
xmllint (libxml2)
'
quiet=true
##
path="$1"
if [ ! -f "$path" ]; then echo "* usage: $0 <filename>"; exit; fi
if $quiet; then curlArgs="-s";fi
filename=$(basename $path)
uploadURL=$(curl -s 'https://webshare.cz/api/upload_url/' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' | xmllint --xpath '//url/text()' -)
ident=$(curl $curlArgs $uploadURL -F "name=$filename" -F "data=@$path" | grep jsonrpc | jq -r '.ident')
if ! $quiet; then echo -ne "\nFILE\t: $filename\nIDENT\t: ";fi
echo "$ident"
@dmnc-net
Copy link
Author

dmnc-net commented Feb 23, 2021

Pro seskupeni vice souboru (napr. i1 a i2) do skupiny: https://webshare.cz/#/group/identSkupiny/
curl 'https://webshare.cz/api/tie_files/' -F "idents[]=$i1" -F "idents[]=$i2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment