upload-files.sh 464 Bytes
#!/bin/sh
set -ex
had_error=0
if [ $# -eq 0 ]; then
	had_error=$(($had_error + 1))
	echo "No files to upload!" 1>&2
fi
if [ "z$UPLOAD_INPUT" = z ]; then
	had_error=$(($had_error + 1))
	echo "UPLOAD_INPUT variable not set!" 1>&2
fi
if [ $had_error -gt 0 ]; then
	exit 1
fi
echo "Upload files: $@"
echo "  from: $UPLOAD_INPUT"

ls -alR "$UPLOAD_INPUT"
for item in "$@"; do
	target="${item%%:*}"
	remote="${item#*:}"
	/s5cmd cp "$UPLOAD_INPUT/$target" "$remote"
done