Files
zulip/tools/setup/install-tusd
Alex Vandiver 818c30372f upload: Use tusd for resumable, larger uploads.
Currently, it handles two hook types: 'pre-create' (to verify that the
user is authenticated and the file size is within the limit) and
'pre-finish' (which creates an attachment row).

No secret is shared between Django and tusd for authentication of the
hooks endpoints, because none is necessary -- tusd forwards the
end-user's credentials, and the hook checks them like it would any
end-user request.  An end-user gaining access to the endpoint would be
able to do no more harm than via tusd or the normal file upload API.

Regardless, the previous commit has restricted access to the endpoint
at the nginx layer.

Co-authored-by: Brijmohan Siyag <brijsiyag@gmail.com>
2024-09-19 11:37:29 -07:00

35 lines
905 B
Bash
Executable File

#!/usr/bin/env bash
set -eu
version=2.5.0
arch="$(uname -m)"
case $arch in
x86_64)
tarball="tusd_linux_amd64"
sha256=f4cbdb8d228b28f46c3e7b9e29e5db262e7416f7ca1033c6c5e8186cf6c7381c
;;
aarch64)
tarball="tusd_linux_arm64"
sha256=b2101951789857765d64c33d672a38b5825946163aa058b208fc862867cdc405
;;
esac
check_version() {
out="$(tusd --version)" && [[ "$out" = *"Version: v$version"* ]]
}
if ! check_version 2>/dev/null; then
set -x
tmpdir="$(mktemp -d)"
trap 'rm -r "$tmpdir"' EXIT
cd "$tmpdir"
curl_opts=(-fLO --retry 3)
curl "${curl_opts[@]}" "https://github.com/tus/tusd/releases/download/v${version}/${tarball}.tar.gz"
sha256sum -c <<<"${sha256} ${tarball}.tar.gz"
tar -xzf "${tarball}.tar.gz" --no-same-owner "${tarball}/tusd"
install -Dm755 "${tarball}/tusd" /usr/local/bin/tusd
check_version
fi