Files
felhom.eu/documentation/audits/rehearsal-2026-10-20/tools/nc_bigchunk.sh
T

17 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# the 1.5 GiB file via Nextcloud's chunked-upload v2 (what its own clients do): MKCOL an upload dir, PUT numbered
# 50 MB chunks, MOVE .file onto the target. Prints status codes only.
set -u
U=odon; B=https://cloud.tester4.test/remote.php/dav; F=/root/data/nextcloud/Csalad/nagy_fajl_1_5GB.bin
ID=rehearsal-$(date +%s); D=$B/files/$U/Csalad/nagy_fajl_1_5GB.bin
c() { curl -sk -u "$U:$PW" -o /dev/null -w "%{http_code}" "$@"; }
echo "MKCOL $(c -X MKCOL -H "Destination: $D" "$B/uploads/$U/$ID")"
SIZE=$(stat -c %s "$F"); CH=$((50*1024*1024)); n=0; off=0; codes=""
while [ $off -lt $SIZE ]; do
n=$((n+1)); name=$(printf '%05d' $n)
code=$(dd if="$F" bs=$CH skip=$((n-1)) count=1 status=none | c -X PUT -H "Destination: $D" -H "OC-Total-Length: $SIZE" --data-binary @- "$B/uploads/$U/$ID/$name")
codes="$codes $code"; off=$((off+CH))
done
echo "PUT $n chunks:$(echo $codes | tr ' ' '\n' | sort | uniq -c | tr '\n' ' ')"
echo "MOVE $(c -X MOVE -H "Destination: $D" -H "OC-Total-Length: $SIZE" "$B/uploads/$U/$ID/.file")"