Skip to content

Instantly share code, notes, and snippets.

@dmnc-net
Last active June 21, 2026 20:20
Show Gist options
  • Select an option

  • Save dmnc-net/5a4e64ac1c21accb377dc8e9f21206ac to your computer and use it in GitHub Desktop.

Select an option

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

dmnc-net commented Feb 23, 2021

Copy link
Copy Markdown
Author

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"

@kalkatit

kalkatit commented Jun 8, 2026

Copy link
Copy Markdown

@dmnc-net Jak by se dal upravit script, aby nahraval soubory pod vlastnym uctem ? Pridani tokenu jako 'wst' nefunguje, resp. soubor se nahra na WS ale ne do mojich souboru.

@dmnc-net

dmnc-net commented Jun 9, 2026

Copy link
Copy Markdown
Author

@kalkatit Nezkousel jsem to, ale tusim, zewst bude nutne poslat jako POST:

uploadURL=$(curl -s -X POST 'https://webshare.cz/api/upload_url/' \
  -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
  --data-urlencode "wst=$WST" \
  | xmllint --xpath '//url/text()' -)

@kalkatit

kalkatit commented Jun 10, 2026

Copy link
Copy Markdown

@dmnc-net Bohuzel, nefunguje. Soubor se sice nahra, ident vracen API, ale soubor neni pod mojim uctem.

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